feat(worker): add worker protocol version#1695
Conversation
🦋 Changeset detectedLatest commit: 26d2d2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 34 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| this.#opts | ||
| .loadFunc(this) | ||
| .then((currentLoad: number) => { | ||
| this.#workerLoad = currentLoad; |
There was a problem hiding this comment.
🟡 Race condition: pending loadFunc promise overwrites #workerLoad after draining sets it to 1
#workerLoad is set to 1 when the draining guard runs at agents/src/worker.ts:687, but a previously-dispatched loadFunc call (which takes ~2.5s via cpuPercent at agents/src/cpu.ts:30-49) can resolve after draining starts and overwrite it at line 710 with a lower value.
Timeline: (1) interval fires, #draining is false, calls loadFunc() → returns a promise that takes ~2.5s; (2) drain() is called, sets #draining = true; (3) next interval fires, sets #workerLoad = 1; (4) the .then() from step 1 runs and sets #workerLoad = currentLoad (potentially < 1). The /worker HTTP endpoint then reports an incorrect load for up to 2.5s while the worker is draining.
| this.#workerLoad = currentLoad; | |
| if (this.#draining) return; | |
| this.#workerLoad = currentLoad; |
Was this helpful? React with 👍 or 👎 to provide feedback.
No description provided.