We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hey! I'm running in the following inconsistency between Miniflare's engine (2.2.0) and other JS runtimes (including the Cloudflare runtime).
Consider the following worker:
class TestError extends Error {} addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { console.log(new Error() instanceof TypeError) console.log(new TypeError() instanceof Error) console.log(new TestError() instanceof Error) console.log(new TestError() instanceof TypeError) console.log(new TestError() instanceof TestError) console.log(new Error() instanceof TestError) console.log(new TypeError() instanceof TestError) return new Response('', { headers: { 'content-type': 'text/plain' }, }) }
On Miniflare, it logs:
false true true false true true true
Whereas with wrangler dev (or just in Node.js or any browser), it logs:
wrangler dev
false true true false true false false
The behaviour is correct for native errors but as soon as we extend Error, every error is considered to be instanceof our custom error on Miniflare.
extend Error
instanceof
Cheers!
The text was updated successfully, but these errors were encountered:
ab60cad
Uh oh! 😟 That's not good! Will be fixed in the next version. 👍
Sorry, something went wrong.
Hey! 👋 I've just released version 2.3.0 including a fix for this. You can find the full changelog here.
2.3.0
Awesome, thanks for the fix and the heads up! ❤️
No branches or pull requests
Hey! I'm running in the following inconsistency between Miniflare's engine (2.2.0) and other JS runtimes (including the Cloudflare runtime).
Consider the following worker:
On Miniflare, it logs:
Whereas with
wrangler dev
(or just in Node.js or any browser), it logs:The behaviour is correct for native errors but as soon as we
extend Error
, every error is considered to beinstanceof
our custom error on Miniflare.Cheers!
The text was updated successfully, but these errors were encountered: