Skip to content

Commit ea775cf

Browse files
committed
fix: connected
1 parent ca90d0b commit ea775cf

File tree

6 files changed

+161
-17
lines changed

6 files changed

+161
-17
lines changed

packages/network-debugger/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-network-devtools",
3-
"version": "1.0.26",
3+
"version": "1.0.27",
44
"description": "Inspecting Node.js's Network with Chrome DevTools",
55
"homepage": "https://grinzero.github.io/node-network-devtools/",
66
"main": "./dist/index.js",
@@ -57,7 +57,9 @@
5757
"vitest": "^2.0.3"
5858
},
5959
"dependencies": {
60+
"bufferutil": "^4.0.9",
6061
"iconv-lite": "^0.6.3",
62+
"inspector": "^0.5.0",
6163
"open": "^8.4.2",
6264
"ws": "^8.17.0"
6365
},

packages/network-debugger/src/fork/devtool/type.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ export interface DevtoolMessageResponse {
99
method?: string
1010
}
1111

12-
export type DevtoolMessage = DevtoolMessageRequest | DevtoolMessageResponse
12+
export interface DevtoolErrorResponse {
13+
id: string
14+
error: { code: number; message?: string }
15+
}
16+
17+
export type DevtoolMessage = DevtoolMessageRequest | DevtoolMessageResponse | DevtoolErrorResponse
1318

1419
export class BaseDevtoolServer {
1520
public timestamp = 0
Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
11
import { createPlugin, useHandler } from '../common'
22

3-
export const healthPlugin = createPlugin('health', () => {
4-
const exitProcess = () => {
5-
process.exit(0)
6-
}
3+
export const healthPlugin = createPlugin('health', ({ devtool }) => {
4+
const notFoundList: string[] = [
5+
'Network.setCacheDisabled',
6+
'Network.enable',
7+
'Network.setAttachDebugStack',
8+
'Page.enable',
9+
'Page.getResourceTree',
10+
'DOM.enable',
11+
'CSS.enable',
12+
'Overlay.enable',
13+
'Overlay.setShowViewportSizeOnResize',
14+
'Emulation.setEmulatedMedia',
15+
'Emulation.setEmulatedVisionDeficiency',
16+
'Animation.enable',
17+
'Autofill.enable',
18+
'Log.enable',
19+
'Autofill.setAddresses',
20+
'Log.startViolationsReport',
21+
'ServiceWorker.enable',
22+
'Audits.enable',
23+
'Inspector.enable',
24+
'Target.setAutoAttach',
25+
'Target.setDiscoverTargets',
26+
'Target.setRemoteLocations',
27+
'Network.clearAcceptedEncodingsOverride',
28+
'DOMDebugger.setBreakOnCSPViolation',
29+
'Page.setAdBlockingEnabled',
30+
'Emulation.setFocusEmulationEnabled',
31+
'Fetch.enable',
32+
'Page.getNavigationHistory',
33+
'Page.startScreencast',
34+
'Page.stopScreencast',
35+
'Overlay.setShowGridOverlays',
36+
'Overlay.setShowFlexOverlays',
37+
'Overlay.setShowScrollSnapOverlays',
38+
'Overlay.setShowContainerQueryOverlays',
39+
'Overlay.setShowIsolatedElements',
40+
'Page.addScriptToEvaluateOnNewDocument'
41+
]
742

8-
let id = setTimeout(exitProcess, 5000)
9-
useHandler('healthcheck', () => {
10-
clearTimeout(id)
11-
id = setTimeout(exitProcess, 5000)
12-
})
43+
for (const method of notFoundList) {
44+
useHandler(method, ({ id }) => {
45+
if (!id) return
46+
devtool.send({
47+
id,
48+
error: {
49+
code: -32601,
50+
message: `'${method}' wasn't found`
51+
}
52+
})
53+
})
54+
}
1355
})

packages/network-debugger/src/fork/module/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import { websocketPlugin } from './websocket'
55
import { healthPlugin } from './health'
66

77
export const loadPlugin = (instance: RequestCenter) => {
8-
instance.loadPlugins([networkPlugin, debuggerPlugin, websocketPlugin, healthPlugin])
8+
instance.loadPlugins([networkPlugin, debuggerPlugin, websocketPlugin])
99
}

packages/network-debugger/vite.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export default defineConfig(({ mode }) => ({
3939
'node:buffer',
4040
'stream',
4141
'net',
42-
'undici'
42+
'undici',
43+
'node:inspector',
44+
'bufferutil'
4345
],
4446
output: {
4547
globals: {
@@ -67,7 +69,9 @@ export default defineConfig(({ mode }) => ({
6769
'node:tls': 'node_tls',
6870
'node:stream': 'node_stream',
6971
'node:querystring': 'node_querystring',
70-
'node:crypto': 'node_crypto'
72+
'node:crypto': 'node_crypto',
73+
'node:inspector': 'node_inspector',
74+
bufferutil: 'bufferutil'
7175
}
7276
}
7377
}

0 commit comments

Comments
 (0)