Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

datacloneerror on postMessage in worker. #979

Closed
snovos opened this issue Dec 16, 2017 · 10 comments · Fixed by #980
Closed

datacloneerror on postMessage in worker. #979

snovos opened this issue Dec 16, 2017 · 10 comments · Fixed by #980

Comments

@snovos
Copy link

snovos commented Dec 16, 2017

Zone modifies Promise by adding extra properties to object, so it cannot be serialized. Is there any workaround for this case?

@JiaLiPassion
Copy link
Collaborator

@snovos , could you provide more information? or a reproduce repo?

@snovos
Copy link
Author

snovos commented Dec 16, 2017

@JiaLiPassion ,Thi is sample code from PDF.js by Mozilla.

Promise.resolve().then(function () {
          return action[0].call(action[1], data.data);
        }).then((result) => {
          comObj.postMessage({
            sourceName,
            targetName,
            isReply: true,
            callbackId: data.callbackId,
            data: result,
          });
        }, (reason) => {
          comObj.postMessage({
            sourceName,
            targetName,
            isReply: true,
            callbackId: data.callbackId,
            error: makeReasonSerializable(reason),
          });
        });

So in reason object I can see some Function type properties, added by zone.

When postMessage is called, reason cannot be serialized since Functions and Errors cannot be cloned and throws DATA_CLONE_ERR. Any ideas?

@JiaLiPassion
Copy link
Collaborator

@snovos , the reason object is a promise or an error? could you post a reproduce repo or plunker? thanks.

@snovos
Copy link
Author

snovos commented Dec 17, 2017

@JiaLiPassion https://github.com/snovos/pdf-zone.

Please run "npm start" and observe that if you pass wong url to component, it throws an error I described above. Please let me know if you were able to reproduce

@JiaLiPassion
Copy link
Collaborator

@snovos, thanks for the reproduce repo, I have made a PR to fix this one.

@snovos
Copy link
Author

snovos commented Dec 18, 2017

@JiaLiPassion Could you please tell me any temporary solution for this case before your fix is merged and released?

@JiaLiPassion
Copy link
Collaborator

@snovos , I can create a branch and can update your zone.js in package.json to point to my branch.

@snovos
Copy link
Author

snovos commented Dec 19, 2017

@JiaLiPassion That would be great. I appreciate it, thanks!

@JiaLiPassion
Copy link
Collaborator

@snovos, you can use this branch ,https://github.com/JiaLiPassion/zone.js/tree/jsondist

@snovos
Copy link
Author

snovos commented Dec 19, 2017

@JiaLiPassion thanks a lot. That works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants