|
1 | 1 | import { createPlugin, useHandler } from '../common' |
2 | 2 |
|
3 | 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 | | - ] |
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) |
54 | 6 | } |
| 7 | + |
| 8 | + let id = setTimeout(exitProcess, 5000) |
| 9 | + useHandler('healthcheck', () => { |
| 10 | + clearTimeout(id) |
| 11 | + id = setTimeout(exitProcess, 5000) |
| 12 | + }) |
55 | 13 | }) |
0 commit comments