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

BUG: Error, Expected signal to be an instanceof AbortSignal #386

Open
bernatfortet opened this issue Sep 21, 2023 · 13 comments
Open

BUG: Error, Expected signal to be an instanceof AbortSignal #386

bernatfortet opened this issue Sep 21, 2023 · 13 comments

Comments

@bernatfortet
Copy link

bernatfortet commented Sep 21, 2023

I'm getting an error Expected signal to be an instanceof AbortSignal when doing any call, e.g. select
I assume, the same issue as #205, #204

I'm using next.js "next": "^13.5.2",
and using Airtable v0.12.2

After digging around I realized it's a node-fetch issues. I ended having to fork the library and edit many parts of it to make it work. Now I"m using my own version. Upgraded node-fetch and it was solved.

I think the issue is here. When doing next dev I'm not getting the issue, but when I'm serving or it's pushed to vercel I'm getting the issue. I think it's because it's not reaching the polyfill or something like that.

What would be the most helpful way to support the team in fixing this issue?

// istanbul ignore file
let AbortController: new () => AbortController;
const browserGlobal =
    typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
if (!browserGlobal) {
    AbortController = require('abort-controller');
} else if ('signal' in new Request('https://airtable.com')) {
    AbortController = browserGlobal.AbortController;
} else {
    const polyfill = require('abortcontroller-polyfill/dist/cjs-ponyfill');
    AbortController = polyfill.AbortController;
}

export default AbortController;
@bernatfortet bernatfortet changed the title Bug, Error: Expected signal to be an instanceof AbortSignal BUG: Error, Expected signal to be an instanceof AbortSignal Sep 22, 2023
@bernatfortet
Copy link
Author

@bendaly818 did you have the same issue?

bernatfortet added a commit to bernatfortet/airtable.js that referenced this issue Oct 1, 2023
@vinayman
Copy link

vinayman commented Oct 3, 2023

I have the same issue @bernatfortet

@vinayman
Copy link

@bernatfortet - Could you commit your changes to a PR? So we can hopefully expedite this change getting merged and a new Airtable.js release being tagged?

@bernatfortet
Copy link
Author

Done: #388

@Khaan25
Copy link

Khaan25 commented Oct 15, 2023

I'm also facing this issue, I hope it's resolved.

@Khaan25
Copy link

Khaan25 commented Oct 15, 2023

@bernatfortet Do you have any current workaround for it?

@Khaan25
Copy link

Khaan25 commented Oct 15, 2023

Hey @bernatfortet I've fixed it. It's a workaround for now but here's the code you need to add:

{ "dependencies": { "airtable": "^0.12.2", "next": "13.5.2", "node-fetch": "^3.3.2", }, "overrides": { "airtable": { "node-fetch": "^3.3.1" } }, "devDependencies": { "@types/airtable": "^0.10.1" } }

@bosung90
Copy link

I was getting the same error when using next14 during build
I fixed by adding following to next.conig.js

experimental: {
    serverMinification: false,
  },

@bernatfortet
Copy link
Author

@bosung90 I assume that by doing serverMinification: false we're preventing next.js from being compressed. That doesn't sound ideal. I wonder if there's any other way to go around it.

@enisze
Copy link

enisze commented Mar 6, 2024

Hey I got the same issue here, sorry to ask, but hows the progress going? 👀

@clawrence121
Copy link

clawrence121 commented Mar 13, 2024

I was able to get it working for Next 14 with the App Router with the following:

  • Next 14.1.3
  • Node 18.17.1
  • Airtable 0.12.2

Working with App Router, Server Actions and Route Handlers, both locally with next start and on vercel.

// package.json
{
  "engines": {
    "node": ">=18.17.0 <19.0.0"
  },
  "dependencies": {
    "airtable": "^0.12.2",
    "next": "14.1.3",
    "node-fetch": "^3.3.2",
  },
  "devDependencies": {
    "@types/airtable": "^0.10.1",
  },
  "overrides": {
    "airtable": {
      "abortcontroller-polyfill": "^1.7.5",
      "node-fetch": "^3.3.2"
    }
  }
}
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    esmExternals: 'loose',
  },
};

module.exports = nextConfig;

Just doing the node-fetch override from above didn't work, I had to add the abortcontroller-polyfill override as well.

@enisze
Copy link

enisze commented Mar 13, 2024

I was able to get it working for Next 14 with the App Router with the following:

  • Next 14.1.3
  • Node 18.17.1
  • Airtable 0.12.2

Working with App Router, Server Actions and Route Handlers, both locally with next start and on vercel.

// package.json
{
  "engines": {
    "node": ">=18.17.0 <19.0.0"
  },
  "dependencies": {
    "airtable": "^0.12.2",
    "next": "14.1.3",
    "node-fetch": "^3.3.2",
  },
  "devDependencies": {
    "@types/airtable": "^0.10.1",
  },
  "overrides": {
    "airtable": {
      "abortcontroller-polyfill": "^1.7.5",
      "node-fetch": "^3.3.2"
    }
  }
}
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    esmExternals: 'loose',
  },
};

module.exports = nextConfig;

Just doing the node-fetch override from above didn't work, I had to add the abortcontroller-polyfill override as well.

This did not work for me @clawrence121 still getting the same error.

It works with this:
serverMinification: false
Although I don't think we should use this.

@evanfurniss
Copy link

Commenting for exposure, same issue with AbortController

  • next: 14.0.4
  • node: 20.9.0
  • airtable: 0.12.2

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

7 participants