-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: --inspect to work inside workers (#2983)
- Loading branch information
1 parent
c2e25bb
commit 36087d1
Showing
9 changed files
with
114 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import inspector from 'node:inspector' | ||
|
||
import type { ResolvedConfig } from '../types' | ||
|
||
/** | ||
* Enables debugging inside `worker_threads` and `child_process`. | ||
* Should be called as early as possible when worker/process has been set up. | ||
*/ | ||
export function setupInspect(config: ResolvedConfig) { | ||
const isEnabled = config.inspect || config.inspectBrk | ||
|
||
if (isEnabled) { | ||
// Inspector may be open already if "isolate: false" is used | ||
const isOpen = inspector.url() !== undefined | ||
|
||
if (!isOpen) { | ||
inspector.open() | ||
|
||
if (config.inspectBrk) | ||
inspector.waitForDebugger() | ||
} | ||
} | ||
|
||
// In watch mode the inspector can persist re-runs if "isolate: false, singleThread: true" is used | ||
const keepOpen = config.watch && !config.isolate && config.singleThread | ||
|
||
return function cleanup() { | ||
if (isEnabled && !keepOpen) | ||
inspector.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters