Closed Bug 830716 Opened 13 years ago Closed 3 years ago

DataCloneError is not helpful

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: Yoric, Assigned: evilpies)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file, 1 obsolete file)

"DataCloneError: The object could not be cloned." is not a really helpful message. What part of my object could not be cloned? Or is it the transferable list that is somehow wrong? Several times, I have found myself spending literally hours trying to find out why my object is not clonable. I would really like more helpful messages.
This would require some JS side assistance.
Assignee: nobody → general
Component: DOM: Workers → JavaScript Engine
Assignee: general → nobody
Here's a horrible patch I created. If you do something like this on the main thread: w.postMessage({ f: function() { console.log('I want RPC!'); } }) You get this lovely printf to stdout: MT DataCloneError coming up on: function () { console.log('I want RPC!'); } And if you do something like this to get yourself a fancy worker doing the same thing... blobby = new Blob(["postMessage({ f: function() { console.log('I want MTV!'); } })"], { type: 'application/javascript' }) z = new Worker(URL.createObjectURL(blobby)) You get this equally lovely printf to stdout: WT DataCloneError coming up on: function () { console.log('I want MTV!'); } And if you do something like this: sketchyFunc = function() { console.log('harmless'); }; sketchyFunc.toString = function() { console.log('moohoohahaha'); return 'sucker!'; }; You get "moohoohahaha" in your console plus: MT DataCloneError coming up on: sucker! (In case it's not clear, besides the whole printf thing, JS gets invoked on the stack with structured cloning going on, which seems like a horrible idea. A less awful patch would just want XPConnect and JS's built-in toString thing going on. I'm sure there's a way to do that.) Also, this patch doesn't do anything with the many, many other sources of DataCloneErrors. (https://dxr.mozilla.org/mozilla-central/search?q=DATA_CLONE_ERR)
Also, note that this specific patch only touches DOM code. I presume the "JS side assistance" khuey is referencing has to do with getting structured cloning to maintain some type of path traversal information and/or having the error type carry a string payload? (Maybe also the XPConnect classes? There seem to be classes involved instead of just bare integer NSRESULTs these days, so maybe things are less hopeless than they used to be when it comes to errors.)
Right, it means that we don't know where the thing we're failing to clone is in relation to the root. Also note that it's possible for cloning to fail for reasons other than just "unrecognized type" (e.g. you can't clone a Function) and Gecko will not get called about those.

The problem is still there for FF 66.
At least the type of the object would be nice to have ("cannot clone a Function" e.g.). Basically any reason would be better than nothing. Firefox prides itself for good development tools and I hope that it will keep the standard high.

Blocks: dom-error

This has one small wrinkle that I might fix in the future: DOM classes that are proxies
like window show up as "Proxy".

Assignee: nobody → evilpies
Status: NEW → ASSIGNED
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/3bdf9fae7d34 Show class-name of object that failed to be cloned. r=smaug

Backed out for causing xpcshell failures on test_ext_runtime_sendMessage_errors.js. CLOSED TREE
Backout link
Push with failures
Link to failure log
Failure line :
TEST-UNEXPECTED-FAIL | xpcshell.ini:toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js | xpcshell return code: 0

Flags: needinfo?(evilpies)
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/2e358af06e5a Show class-name of object that failed to be cloned. r=smaug

Backed out changeset 2e358af06e5a (Bug 830716) for causing xpcshell failures on test_promise_unhandled_rejection.js.
Backout link
Push with failures <--> x2
Failure Log

Attachment #8632598 - Attachment is obsolete: true
Flags: needinfo?(evilpies)
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/6b76fb554f2f Show class-name of object that failed to be cloned. r=smaug
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: