Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
5af38f17
Unverified
Commit
5af38f17
authored
May 18, 2020
by
Mario Pareja
Committed by
GitHub
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix crash when NODE_OPTIONS includes --inspect-port (#12555)
parent
c334a275
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletion
+54
-1
utils.ts
packages/next/server/lib/utils.ts
+1
-1
get-node-options-without-inspect.test.js
test/unit/get-node-options-without-inspect.test.js
+53
-0
No files found.
packages/next/server/lib/utils.ts
View file @
5af38f17
...
@@ -10,6 +10,6 @@ export function printAndExit(message: string, code = 1) {
...
@@ -10,6 +10,6 @@ export function printAndExit(message: string, code = 1) {
}
}
export
function
getNodeOptionsWithoutInspect
()
{
export
function
getNodeOptionsWithoutInspect
()
{
const
NODE_INSPECT_RE
=
/--inspect
(
-brk
)?(
=
\S
+
)?
?
/
const
NODE_INSPECT_RE
=
/--inspect
(
-brk
)?(
=
\S
+
)?
(
|$
)
/
return
(
process
.
env
.
NODE_OPTIONS
||
''
).
replace
(
NODE_INSPECT_RE
,
''
)
return
(
process
.
env
.
NODE_OPTIONS
||
''
).
replace
(
NODE_INSPECT_RE
,
''
)
}
}
test/unit/get-node-options-without-inspect.test.js
0 → 100644
View file @
5af38f17
/* eslint-env jest */
import
{
getNodeOptionsWithoutInspect
}
from
'next/dist/server/lib/utils'
const
originalNodeOptions
=
process
.
env
.
NODE_OPTIONS
afterAll
(()
=>
{
process
.
env
.
NODE_OPTIONS
=
originalNodeOptions
})
describe
(
'getNodeOptionsWithoutInspect'
,
()
=>
{
it
(
'removes --inspect option'
,
()
=>
{
process
.
env
.
NODE_OPTIONS
=
'--other --inspect --additional'
const
result
=
getNodeOptionsWithoutInspect
()
expect
(
result
).
toBe
(
'--other --additional'
)
})
it
(
'removes --inspect option at end of line'
,
()
=>
{
process
.
env
.
NODE_OPTIONS
=
'--other --inspect'
const
result
=
getNodeOptionsWithoutInspect
()
expect
(
result
).
toBe
(
'--other '
)
})
it
(
'removes --inspect option with parameters'
,
()
=>
{
process
.
env
.
NODE_OPTIONS
=
'--other --inspect=0.0.0.0:1234 --additional'
const
result
=
getNodeOptionsWithoutInspect
()
expect
(
result
).
toBe
(
'--other --additional'
)
})
it
(
'removes --inspect-brk option'
,
()
=>
{
process
.
env
.
NODE_OPTIONS
=
'--other --inspect-brk --additional'
const
result
=
getNodeOptionsWithoutInspect
()
expect
(
result
).
toBe
(
'--other --additional'
)
})
it
(
'removes --inspect-brk option with parameters'
,
()
=>
{
process
.
env
.
NODE_OPTIONS
=
'--other --inspect-brk=0.0.0.0:1234 --additional'
const
result
=
getNodeOptionsWithoutInspect
()
expect
(
result
).
toBe
(
'--other --additional'
)
})
it
(
'ignores unrelated options starting with --inspect-'
,
()
=>
{
process
.
env
.
NODE_OPTIONS
=
'--other --inspect-port=0.0.0.0:1234 --additional'
const
result
=
getNodeOptionsWithoutInspect
()
expect
(
result
).
toBe
(
'--other --inspect-port=0.0.0.0:1234 --additional'
)
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment