Skip to content

Commit 276a79d

Browse files
committed
Avoid Segmentation Fault
1 parent c5028df commit 276a79d

File tree

11 files changed

+20
-36
lines changed

11 files changed

+20
-36
lines changed

packages/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"test:integration": "./test/run-integration-tests.sh && yarn test:types",
7171
"test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)",
7272
"test:integration:client": "yarn playwright test test/integration/test/client/",
73-
"test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && jest --config=test/integration/jest.config.js test/integration/test/server/",
73+
"test:integration:server": "(cd test/integration && yarn test:server)",
7474
"test:types": "cd test/types && yarn test",
7575
"test:watch": "jest --watch",
7676
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",

packages/nextjs/test/integration/next12.config.template

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const { withSentryConfig } = require('@sentry/nextjs');
22

3-
// NOTE: This will be used by integration tests to distinguish between Webpack 4 and Webpack 5
43
const moduleExports = {
5-
webpack5: %RUN_WEBPACK_5%,
64
eslint: {
75
ignoreDuringBuilds: true,
86
},
@@ -11,10 +9,7 @@ const moduleExports = {
119
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
1210
// TODO (v8): This can come out in v8, because this option will get a default value
1311
hideSourceMaps: false,
14-
excludeServerRoutes: [
15-
'/api/excludedEndpoints/excludedWithString',
16-
/\/api\/excludedEndpoints\/excludedWithRegExp/,
17-
],
12+
excludeServerRoutes: ['/api/excludedEndpoints/excludedWithString', /\/api\/excludedEndpoints\/excludedWithRegExp/],
1813
},
1914
};
2015

packages/nextjs/test/integration/next13.config.template

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const { withSentryConfig } = require('@sentry/nextjs');
22

3-
// NOTE: This will be used by integration tests to distinguish between Webpack 4 and Webpack 5
43
const moduleExports = {
5-
webpack5: %RUN_WEBPACK_5%,
64
eslint: {
75
ignoreDuringBuilds: true,
86
},
@@ -14,10 +12,7 @@ const moduleExports = {
1412
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
1513
// TODO (v8): This can come out in v8, because this option will get a default value
1614
hideSourceMaps: false,
17-
excludeServerRoutes: [
18-
'/api/excludedEndpoints/excludedWithString',
19-
/\/api\/excludedEndpoints\/excludedWithRegExp/,
20-
],
15+
excludeServerRoutes: ['/api/excludedEndpoints/excludedWithString', /\/api\/excludedEndpoints\/excludedWithRegExp/],
2116
},
2217
};
2318

packages/nextjs/test/integration/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"predebug": "source ../integration_test_utils.sh && link_monorepo_packages '../../..' && yarn build",
88
"start": "next start",
99
"pretest": "yarn build",
10-
"test": "playwright test"
10+
"test:client": "playwright test",
11+
"test:server": "jest --detectOpenHandles --forceExit --runInBand"
1112
},
1213
"dependencies": {
1314
"@sentry/nextjs": "file:../../",
@@ -20,7 +21,7 @@
2021
"@types/react": "17.0.47",
2122
"@types/react-dom": "17.0.17",
2223
"nock": "^13.1.0",
23-
"typescript": "^4.5.2",
24+
"typescript": "^4.2.4",
2425
"yargs": "^16.2.0"
2526
},
2627
"resolutions": {

packages/nextjs/test/integration/test/server/errorApiEndpoint.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { NextTestEnv } from './utils/helpers';
22

3-
jest.spyOn(console, 'error').mockImplementation();
4-
53
describe('Error API Endpoints', () => {
64
it('should capture an error event', async () => {
75
const env = await NextTestEnv.init();

packages/nextjs/test/integration/test/server/utils/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export class NextTestEnv extends TestEnv {
1414
const server = await createNextServer({
1515
dev: false,
1616
dir: path.resolve(__dirname, '../../..'),
17+
18+
// This needs to be explicitly passed to the server
19+
// Otherwise it causes Segmentation Fault with NextJS >= 12
20+
// https://github.com/vercel/next.js/issues/33008
21+
conf: path.resolve(__dirname, '../../next.config.js'),
1722
});
1823

1924
await startServer(server, port);

packages/nextjs/test/integration/test/utils/common.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import { createServer, Server } from 'http';
22
import { parse } from 'url';
33
import { promises, PathLike } from 'fs';
44
import next from 'next';
5-
import { NextServer } from 'next/dist/server/next';
65

76
const { stat } = promises;
87

98
// Type not exported from NextJS
10-
type NextServerConstructor = ConstructorParameters<typeof NextServer>[0];
11-
12-
export const createNextServer = async (config: NextServerConstructor) => {
9+
// @ts-ignore
10+
export const createNextServer = async config => {
1311
const app = next(config);
1412
const handle = app.getRequestHandler();
1513
await app.prepare();

packages/nextjs/test/integration/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"allowJs": true,
4+
"allowSyntheticDefaultImports": true,
45
"alwaysStrict": true,
56
"esModuleInterop": true,
67
"forceConsistentCasingInFileNames": true,

packages/nextjs/test/integration/tsconfig.test.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"include": ["test/**/*"],
55

66
"compilerOptions": {
7-
"types": ["node", "jest"],
8-
"esModuleInterop": true
7+
"types": ["node", "jest"]
98
}
109
}

packages/nextjs/test/tsconfig.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,5 @@
44
{
55
"extends": "../tsconfig.test.json",
66

7-
"include": ["./**/*", "../playwright.config.ts"],
8-
9-
"compilerOptions": {
10-
"types": ["node", "jest"],
11-
"esModuleInterop": true
12-
}
7+
"include": ["./**/*", "../playwright.config.ts"]
138
}

packages/node-integration-tests/utils/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ export class TestEnv {
269269
url?: string;
270270
timeout?: number;
271271
envelopeType: EnvelopeItemType | EnvelopeItemType[];
272-
endServer?: boolean;
273272
}): Promise<number> {
274273
return new Promise(resolve => {
275274
let reqCount = 0;
@@ -290,13 +289,11 @@ export class TestEnv {
290289
setTimeout(() => {
291290
nock.removeInterceptor(mock);
292291

293-
if (options.endServer) {
294-
nock.cleanAll();
292+
nock.cleanAll();
295293

296-
this.server.close(() => {
297-
resolve(reqCount);
298-
});
299-
}
294+
this.server.close(() => {
295+
resolve(reqCount);
296+
});
300297

301298
resolve(reqCount);
302299
}, options.timeout || 1000);

0 commit comments

Comments
 (0)