-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(v8/node): Enforce that ContextLines integration does not leave op…
- Loading branch information
1 parent
286f6b0
commit f5ac627
Showing
12 changed files
with
292 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...gration-tests/suites/contextLines/test.ts → ...contextLines/filename-with-spaces/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
dev-packages/node-integration-tests/suites/contextLines/memory-leak/nested-file.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as Sentry from '@sentry/node'; | ||
|
||
export function captureException(i: number): void { | ||
Sentry.captureException(new Error(`error in loop ${i}`)); | ||
} |
7 changes: 7 additions & 0 deletions
7
dev-packages/node-integration-tests/suites/contextLines/memory-leak/other-file.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { captureException } from './nested-file'; | ||
|
||
export function runSentry(): void { | ||
for (let i = 0; i < 10; i++) { | ||
captureException(i); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
dev-packages/node-integration-tests/suites/contextLines/memory-leak/scenario.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { execSync } from 'node:child_process'; | ||
import * as path from 'node:path'; | ||
|
||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
transport: loggingTransport, | ||
}); | ||
|
||
import { runSentry } from './other-file'; | ||
|
||
runSentry(); | ||
|
||
const lsofOutput = execSync(`lsof -p ${process.pid}`, { encoding: 'utf8' }); | ||
const lsofTable = lsofOutput.split('\n'); | ||
const mainPath = __dirname.replace(`${path.sep}suites${path.sep}contextLines${path.sep}memory-leak`, ''); | ||
const numberOfLsofEntriesWithMainPath = lsofTable.filter(entry => entry.includes(mainPath)); | ||
|
||
// There should only be a single entry with the main path, otherwise we are leaking file handles from the | ||
// context lines integration. | ||
if (numberOfLsofEntriesWithMainPath.length > 1) { | ||
// eslint-disable-next-line no-console | ||
console.error('Leaked file handles detected'); | ||
// eslint-disable-next-line no-console | ||
console.error(lsofTable); | ||
process.exit(1); | ||
} |
17 changes: 17 additions & 0 deletions
17
dev-packages/node-integration-tests/suites/contextLines/memory-leak/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { conditionalTest } from '../../../utils'; | ||
import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; | ||
|
||
conditionalTest({ min: 18 })('ContextLines integration in CJS', () => { | ||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
// Regression test for: https://github.com/getsentry/sentry-javascript/issues/14892 | ||
test('does not leak open file handles', done => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.expectN(10, { | ||
event: {}, | ||
}) | ||
.start(done); | ||
}); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters