Closed
Description
Ethers Version
5.7.2
Search Terms
No response
Describe the Problem
In a Worker, it seems like fetch
behaves differently:
const provider = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/eth');
provider.on('debug', console.log);
provider.on('error', console.log);
await provider.getNetwork();
Uncaught Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
at Logger.makeError (ethers-5.7.2.umd.min.js:1:62180)
at Logger.throwError (ethers-5.7.2.umd.min.js:1:62385)
at JsonRpcProvider.<anonymous> (ethers-5.7.2.umd.min.js:1:655650)
at step (ethers-5.7.2.umd.min.js:1:642267)
at Object.throw (ethers-5.7.2.umd.min.js:1:641527)
at rejected (ethers-5.7.2.umd.min.js:1:640986)
The cause is the following error: Failed to execute 'fetch' on 'WorkerGlobalScope': Referrer 'client' is not a valid URL.
, which is set here:
It seems this was discussed in #1886 but I'm not sure how to turn it on. Given that this affects vanilla JS and not an esoteric platform, maybe the behavior can be changed to be more flexible?
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
Browser (Chrome, Safari, etc)
Environment (Other)
No response