Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Prevent node inspect from causing webpack check to fail (vercel#25876)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Jun 8, 2021
1 parent 4c3e8a3 commit d7c8006
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/next/next-server/server/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ function reasonMessage(reason: CheckReasons) {
export async function loadWebpackHook(phase: string, dir: string) {
let useWebpack5 = true
let usesRemovedFlag = false
const worker: any = new Worker(
const worker = new Worker(
path.resolve(__dirname, './config-utils-worker.js'),
{
enableWorkerThreads: false,
numWorkers: 1,
forkOptions: {
env: {
...process.env,
NODE_OPTIONS: '',
},
},
}
)
) as Worker & {
shouldLoadWithWebpack5: typeof import('./config-utils-worker').shouldLoadWithWebpack5
}
try {
const result: CheckResult = await worker.shouldLoadWithWebpack5(phase, dir)
if (result.reason === 'future-flag') {
Expand Down
20 changes: 19 additions & 1 deletion test/integration/config/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ jest.setTimeout(1000 * 60 * 5)

describe('Configuration', () => {
beforeAll(async () => {
context.output = ''

const handleOutput = (msg) => {
context.output += msg
}

context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort)
context.server = await launchApp(join(__dirname, '../'), context.appPort, {
env: {
NODE_OPTIONS: '--inspect',
},
onStdout: handleOutput,
onStderr: handleOutput,
})

// pre-build all pages at the start
await Promise.all([
Expand All @@ -40,6 +52,12 @@ describe('Configuration', () => {
return cheerio.load(html)
}

it('should log webpack version correctly', async () => {
expect(context.output).toContain(
`Using webpack 4. Reason: webpack5 flag is set to false in next.config.js`
)
})

it('should disable X-Powered-By header support', async () => {
const url = `http://localhost:${context.appPort}/`
const header = (await fetch(url)).headers.get('X-Powered-By')
Expand Down

0 comments on commit d7c8006

Please sign in to comment.