Skip to content

Commit 7e314ce

Browse files
committed
feat: use healthcheck
1 parent ea775cf commit 7e314ce

File tree

3 files changed

+10
-52
lines changed

3 files changed

+10
-52
lines changed

packages/network-debugger/src/core/fork.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class MainProcess {
142142
const ping = () => {
143143
ws.send(
144144
JSON.stringify({
145-
type: 'health',
145+
type: 'healthcheck',
146146
data: {}
147147
})
148148
)
Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,13 @@
11
import { createPlugin, useHandler } from '../common'
22

33
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-
]
42-
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-
})
4+
const exitProcess = () => {
5+
process.exit(0)
546
}
7+
8+
let id = setTimeout(exitProcess, 5000)
9+
useHandler('healthcheck', () => {
10+
clearTimeout(id)
11+
id = setTimeout(exitProcess, 5000)
12+
})
5513
})

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])
8+
instance.loadPlugins([healthPlugin, networkPlugin, debuggerPlugin, websocketPlugin])
99
}

0 commit comments

Comments
 (0)