Prevent node inspect from causing webpack check to fail (#25876)

This commit is contained in:
JJ Kasper 2021-06-08 02:23:08 -05:00 committed by GitHub
parent 583b5b9d2d
commit 18f8198954
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 3 deletions

View file

@ -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') {

View file

@ -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([
@ -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')