Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid Segmentation Fault
  • Loading branch information
onurtemizkan committed Jan 25, 2023
commit 276a79dfe8f90cc0a5f5a2312f307d0fa72d265d
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"test:integration": "./test/run-integration-tests.sh && yarn test:types",
"test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)",
"test:integration:client": "yarn playwright test test/integration/test/client/",
"test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && jest --config=test/integration/jest.config.js test/integration/test/server/",
"test:integration:server": "(cd test/integration && yarn test:server)",
"test:types": "cd test/types && yarn test",
"test:watch": "jest --watch",
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",
Expand Down
7 changes: 1 addition & 6 deletions packages/nextjs/test/integration/next12.config.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { withSentryConfig } = require('@sentry/nextjs');

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

Expand Down
7 changes: 1 addition & 6 deletions packages/nextjs/test/integration/next13.config.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { withSentryConfig } = require('@sentry/nextjs');

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

Expand Down
5 changes: 3 additions & 2 deletions packages/nextjs/test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"predebug": "source ../integration_test_utils.sh && link_monorepo_packages '../../..' && yarn build",
"start": "next start",
"pretest": "yarn build",
"test": "playwright test"
"test:client": "playwright test",
"test:server": "jest --detectOpenHandles --forceExit --runInBand"
},
"dependencies": {
"@sentry/nextjs": "file:../../",
Expand All @@ -20,7 +21,7 @@
"@types/react": "17.0.47",
"@types/react-dom": "17.0.17",
"nock": "^13.1.0",
"typescript": "^4.5.2",
"typescript": "^4.2.4",
"yargs": "^16.2.0"
},
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { NextTestEnv } from './utils/helpers';

jest.spyOn(console, 'error').mockImplementation();

describe('Error API Endpoints', () => {
it('should capture an error event', async () => {
const env = await NextTestEnv.init();
Expand Down
5 changes: 5 additions & 0 deletions packages/nextjs/test/integration/test/server/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export class NextTestEnv extends TestEnv {
const server = await createNextServer({
dev: false,
dir: path.resolve(__dirname, '../../..'),

// This needs to be explicitly passed to the server
// Otherwise it causes Segmentation Fault with NextJS >= 12
// https://github.com/vercel/next.js/issues/33008
conf: path.resolve(__dirname, '../../next.config.js'),
});

await startServer(server, port);
Expand Down
6 changes: 2 additions & 4 deletions packages/nextjs/test/integration/test/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { createServer, Server } from 'http';
import { parse } from 'url';
import { promises, PathLike } from 'fs';
import next from 'next';
import { NextServer } from 'next/dist/server/next';

const { stat } = promises;

// Type not exported from NextJS
type NextServerConstructor = ConstructorParameters<typeof NextServer>[0];

export const createNextServer = async (config: NextServerConstructor) => {
// @ts-ignore
export const createNextServer = async config => {
const app = next(config);
const handle = app.getRequestHandler();
await app.prepare();
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/test/integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/test/integration/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "jest"],
"esModuleInterop": true
"types": ["node", "jest"]
}
}
7 changes: 1 addition & 6 deletions packages/nextjs/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@
{
"extends": "../tsconfig.test.json",

"include": ["./**/*", "../playwright.config.ts"],

"compilerOptions": {
"types": ["node", "jest"],
"esModuleInterop": true
}
"include": ["./**/*", "../playwright.config.ts"]
}
11 changes: 4 additions & 7 deletions packages/node-integration-tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ export class TestEnv {
url?: string;
timeout?: number;
envelopeType: EnvelopeItemType | EnvelopeItemType[];
endServer?: boolean;
}): Promise<number> {
return new Promise(resolve => {
let reqCount = 0;
Expand All @@ -290,13 +289,11 @@ export class TestEnv {
setTimeout(() => {
nock.removeInterceptor(mock);

if (options.endServer) {
nock.cleanAll();
nock.cleanAll();

this.server.close(() => {
resolve(reqCount);
});
}
this.server.close(() => {
resolve(reqCount);
});

resolve(reqCount);
}, options.timeout || 1000);
Expand Down