deno
59f13eed - fix(node): make Worker.startCpuProfile match Node lifecycle and return type

Commit
23 days ago
fix(node): make Worker.startCpuProfile match Node lifecycle and return type Finishes the follow-up left by the previous commit and fixes two Node compatibility gaps found while re-enabling the test: - Keep the worker alive while a CPU profile is active (between `startCpuProfile()` and `handle.stop()`). Previously a worker that went idle mid-profile would terminate before `stop()` resolved, so the promise hung. `hasMessageEventListener()` now treats a non-zero active-profile count as a reason to keep the worker running, matching Node. - Reject in-flight `startCpuProfile()`/`stop()` promises with ERR_WORKER_NOT_RUNNING when the worker exits before replying, instead of hanging forever. Node rejects in this case (e.g. profiling a worker that has already idle-exited). - `handle.stop()` now resolves with the raw profile JSON string, matching Node (whose `CPUProfileHandle.stop()` returns `Promise<string>`), so the result can be written straight to a `.cpuprofile` file. It previously resolved with a parsed object. The vendored d.ts is updated to match upstream @types/node (`CPUProfileOptions`, `stop(): Promise<string>`). Re-enables the `Worker.startCpuProfile` unit test and adds coverage for the keep-alive and reject-on-exit paths. Refs #35250
Author
Parents
Loading