postMessage fails for {Readable,Writable}Stream in Safari
What type of issue is this?
Browser bug (a bug with a feature that may impact site compatibility)
What information was incorrect, unhelpful, or incomplete?
The Browser Compatibility section shows Safari and Safari iOS fully support postMessage, but the API fails when transferring a ReadableStream or WritableStream.
What browsers does this problem apply to, if applicable?
Safari
What did you expect to see?
Successful transfer of the readable stream to the postMessage destination.
Did you test this? If so, how?
Run the following in the console to test:
let rs = new ReadableStream()
postMessage(rs, '*', [rs])
Chrome et al will log something like this:
▶︎ undefined
Safari will log this:
▶︎ DataCloneError: The object can not be cloned.
Can you link to any release notes, bugs, pull requests, or MDN pages related to this?
https://bugs.webkit.org/show_bug.cgi?id=215485
Do you have anything more you want to share?
This is true of all postMessage implementations (service workers, message ports, etc), and also for structuredClone.
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
MDN metadata
MDN page report details
- Query:
api.Window.postMessage - Report started: 2024-10-05T18:25:32.327Z
See https://github.com/mdn/browser-compat-data/issues/24642#issuecomment-2395524811
The BCD tables for both ReadableStream and WritableStream contain this information as "transferable" subfeatures (added in https://github.com/mdn/browser-compat-data/pull/16525), stating that Safari does not support this.