| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The React and Vue loaders registered a global `window` error listener while the parcelLab bundle was downloading, and treated anything it caught as a parcelLab load failure. Because that event fires for every uncaught error on the host page, an unrelated third-party script throwing during the download window made the loader skip `initialize()` entirely and the widget never rendered. This is what happened on unisport.pl: Bazaarvoice threw "not configured for the domain", our bundle then loaded perfectly well, and the loader discarded it. Any customer running a third-party script that throws is exposed. The listener is replaced with a check for the global the bundle publishes as its final statement. A script that throws while executing still fires `load`, so the absence of that global is a precise signal that *our* script failed, and nothing else on the page can trigger it. Also fixed in the same path: - The 15s timeout only recorded an error and never rejected, so a bundle that never loaded left the promise pending forever. It now settles, and resolves if the global did appear in the meantime. - `reject()` was not followed by `return`, falling through to `resolve()`. - React bootstrapped off `[tntRef.current]`, which changes from undefined to the element after first render, so any re-render appended a second script and initialised twice. Now guarded to run once per mount. - The committed Vue artifacts were webpack *development* builds using eval(), which a strict CSP blocks outright. Rebuilt as production bundles; v5/vue/index.js drops from 16.7 kB to 7.5 kB. All four loaders (v3 and v5, React and Vue) carried the same bug. v3 had no global check at all, so one was added. Adds vitest + jsdom coverage: 44 tests, of which 19 fail against the previous code. Tests run against the committed build artifacts as well as src/, and CI now rebuilds and fails if the two have drifted.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Sorry, something went wrong.
vitest 4 imports styleText from node:util, which requires Node 20+. The deploy workflow's Node 18 stays as-is; it only runs AWS CLI steps.
Bump 1.0.6 -> 1.0.7 so the REQ-6294 loader fix can be published. npm rejects republishing an existing version, so #28 is unreleasable as-is. Also corrects the release note added in #28: the React and Vue entry points are published to public npm, not GitHub Packages. Replaces it with the actual publish steps, including the version bump that the internal runbook omits.
| Back | FazBrowse Home | New Git URL |
Related Ticket
https://parcellab.atlassian.net/browse/REQ-6294
The bug
The React and Vue loaders registered a global window error listener for the whole duration of the parcelLab bundle download, and treated whatever it caught as a parcelLab load failure:
window's error event fires for every uncaught exception anywhere on the host page. On unisport.pl, Bazaarvoice threw not configured for the domain, our bundle then loaded perfectly well, and the loader threw it away — so initialize() was never called and Track & Trace never rendered. Nothing compared the event against our script.
Unisport is just the visible victim. Any customer running a third-party script that throws — analytics, chat, session replay, ad tags, A/B testing, cookie banners — is exposed to the same latent failure.
The fix
Delete the listener and lean on a signal that is already precise.
The plugin bundle publishes its global as its final statement (Object.defineProperty(window, "parcelLabTrackAndTrace", …)). A script that throws mid-execution still fires load, so the global being absent means our code failed — and nothing on the host page can cause it. v5 already had this check sitting unused next to the buggy one; v3 had none and now does.
Also fixed on the same path
Scope
All four loaders had the bug, not just the one named in the ticket: v3 and v5, React and Vue.
Tests
44 tests (vitest + jsdom), 19 of which fail against the previous code — so they genuinely pin the regression rather than just describing the new behaviour.
The suite covers, per loader: init survives an unrelated third-party error; no global error listener is registered at all; genuine failures (bundle loaded but global missing, script 404, timeout) still surface; bootstrap happens exactly once.
Because v3/ and v5/ are committed build artifacts that npm publishes, the tests also run against the built output, not just src/. And CI now rebuilds and fails if the committed artifacts have drifted from src/ — this repo's easiest mistake is fixing src/ and shipping nothing.
Reviewer notes
Follow-ups, deliberately not in this PR
Test plan