Disclaimer: I'm not totally sure about the root cause here, but something needs fixing either in WebKit, WPT, or BCD. In BCD, the messageerror event for ServiceWorkerGlobalScope is marked as partially supported in Safari, because the event never fires: https://github.com/mdn/browser-compat-data/blob/7752b0a038a04ee47f112e696706bd53a589b0c6/api/ServiceWorkerGlobalScope.json#L617 That refers to https://bugs.webkit.org/show_bug.cgi?id=171216, which is closed as fixed. But from the patch it's not easy to tell if the event actually fires now or not. Turning to WPT, this test failure suggests that the event doesn't fire: https://wpt.fyi/results/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-serviceworker-failure.https.html?run_id=5176510071177216&run_id=5153332145946624&run_id=5195972581261312&run_id=5076778648862720 The failure message points to this line of the test being reached: https://github.com/web-platform-tests/wpt/blob/1cafd038c989f47a1e136844d09ca85a06f85ce0/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/serviceworker-failure.js#L16C27-L16C55 So my best guess is that WebKit doesn't fire the messageerror event on ServiceWorkerGlobalScope, and instead fires a message event with data being set to null.
<rdar://problem/127104436>
We do have following FIXME: FIXME: Add support for messageerror event when message deserialization fails. https://searchfox.org/wubkat/rev/53d24706292c592556c5991a08e75e3066495105/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp#149
Pull request: https://github.com/WebKit/WebKit/pull/27974
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/46003
Committed 278408@main (fddda893fc92): <https://commits.webkit.org/278408@main> Reviewed commits have been landed. Closing PR #27974 and removing active labels.