Skip to content

fix: fall back when heartbeat worker fails - #752

Open
JangHyeok2909 wants to merge 1 commit into
stomp-js:developfrom
JangHyeok2909:fix/worker-heartbeat-fallback
Open

JangHyeok2909 wants to merge 1 commit into
stomp-js:developfrom
JangHyeok2909:fix/worker-heartbeat-fallback

Conversation

@JangHyeok2909

Copy link
Copy Markdown

Summary

  • fall back to the interval ticker when Web Worker construction throws or the Worker emits an asynchronous error
  • terminate failed Workers and ignore late errors from Workers that have already been stopped or replaced
  • revoke the heartbeat Worker's blob URL on both success and failure paths
  • add regression coverage and an unreleased changelog entry

Closes #751.

Why

A strict Content Security Policy can allow same-origin workers while rejecting blob: workers. In current Chrome, new Worker(blobUrl) still returns a Worker and the CSP rejection arrives later through the Worker's error event. Without an error handler, outgoing heartbeat ticks stop even though the STOMP connection can finish connecting.

Synchronous initialization failures also currently escape from heartbeat setup, and each reconnect leaves another object URL allocated.

The fallback matches the existing behavior used when Web Workers are unavailable.

Verification

  • Control run: after adding the regression assertions but before changing Ticker, the suite reproduced three failures—missing URL revocation, an escaping constructor error, and no fallback after an asynchronous Worker error.
  • The focused ticker suite passes all 8 tests, including a late-error-after-stop guard.
  • The complete Node project passes all 146 tests against the repository's RabbitMQ 3.10.25 Web STOMP fixture.
  • The built code was exercised in Chrome 156 with two CSP controls: worker-src blob: used the Worker normally; worker-src 'self' produced the CSP error and continued ticking through the interval fallback.
  • TypeScript compilation, the production build, Prettier checks, and diff checks pass. ESLint reports no errors; its existing no-explicit-any warnings remain unchanged.

@kum-deepak

Copy link
Copy Markdown
Member

Many thanks for the PR. I have done a brief review of the code. I need to review the test cases. I need to ensure that the test cases use a similar pattern to the existing test cases.

I will merge it after reviewing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker heartbeat silently stops when CSP blocks blob workers

2 participants