question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to remove "TypeError: Expected signal to be an instanceof AbortSignal"?

See original GitHub issue

https://github.com/node-fetch/node-fetch/blob/master/src/request.js?ts=2#L120

This line causing problem

image

Let’s check out ths isAbortSignal function

image

When would it happen?

After Webpack bundle my code, code minification would change the name,
object[NAME] === 'AbortSignal' is not true anymore so this error would pop up, The only solution is to turn off code minification There should be a better way than this

Propose (What to do next)

  1. Delete this part altogether, don’t check the name
  2. Don’t compare with string ‘AbortSignal’ like this object[NAME] === 'AbortSignal', in Ruby we have class.name to get the class name, I am not sure what’s the equivalent in JS

Maybe this StackOverflow question helpful: How to get a JavaScript object’s class?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
domgenvcommented, Jan 17, 2022

For those using esbuild, an equivalent solution to 1c7’s solution is to set the “keepNames” option to true.

https://esbuild.github.io/api/#keep-names

7reactions
1c7commented, Apr 23, 2020

Done, fixed it

Enviroment

  • Electron.js 8.0.0
  • “vue-cli-plugin-electron-builder”: “^1.4.5”
  • @azure/storage-blob”: “12.1.1”

Solution:

This can still minify code, but, without mangle with the class name and function name

vue.config.js

const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
 pluginOptions: {
  electronBuilder: {
   chainWebpackMainProcess: config => {
    config.plugins.delete('uglify')
    config.plugin('uglify').use(TerserPlugin, [{
     terserOptions: {
      mangle: false,
      sourceMap: true,
      compress: false,
      keep_classnames: true,
      keep_fnames: true,
      output: {
       comments: false,
      },
     }
    }])
    config.optimization.minimize(false);
    console.log(config.toString())
   },
  }
 },
}

Result (This worked)

This is src/background.js file after running npm run electron:build

image

For comparison (This doesn’t work)

node-fetch would raise error image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error with Lambda Function running on NodeJS netlify ...
My function always seems to return an error in development which says Function invocation failed: TypeError: Expected signal to be an instanceof ......
Read more >
[JS Client] Expected signal to be an instanceof AbortSignal
When webpacking in production mode for nodejs an application that uses Ktor JS client with new IR compialtion backend and running it, any...
Read more >
AbortSignal - Web APIs - MDN Web Docs - Mozilla
The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a fetch request) and abort ......
Read more >
The complete guide to AbortController in Node.js
Introduction to AbortSignal; How to use AbortSignal to time out async ... The code below shows how to add and remove the abort...
Read more >
Realm js: Expected signal to be an instanceof AbortSignal
Hi! i am using realm node sdk with electron-forge configuration and also creating an api with contextBridge. when i load the application in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found