Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': function transformRequest(data, headers) { normalizeHeaderName(headers, 'Accept'); normalizeHeaderName(...<omitted>... } could not be cloned. #121

Open
CurryChou777 opened this issue Nov 5, 2021 · 1 comment

Comments

@CurryChou777
Copy link

I query a large Firebase collection in my app.
I'd like to use axios in my app. But it is wrong

`
// worker.js

import axios from "axios";
import 'regenerator-runtime';

export async function expensive() {
const res = await axios.get('https://vdata.amap.com/tiles?mapType=normal&v=3&style=5&key=f97efc35164149d0c0f299e7a8adb3d2&version=1.4.17&rd=2&flds=roadlabel,poilabel&t=9,432,204;9,436,204;9,432,201;9,436,201;9,432,203;9,436,203;9,433,204;9,435,204;9,432,202;9,436,202&lv=9&key=f97efc35164149d0c0f299e7a8adb3d2&preload=0');
console.log(res)
return res;
}
`
When I run the worker as follows:

// app.js
import Worker from 'workerize-loader!./worker';

`
let instance = worker()

instance.expensive().then(data => {
  console.log(`${data}`)
})

`

Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': function transformRequest(data, headers) { normalizeHeaderName(headers, 'Accept'); normalizeHeaderName(...... } could not be cloned.

Is it a bug in workerize or is it me doing something wrong?

@jonsalvas
Copy link

I had the same issue and it appears that it is caused by axios while trying to clone the whole response response object with all functions etc. which cannot be cloned for security reasons. If you however return res.data in the worker instead of res it should work.

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

No branches or pull requests

2 participants