Airtable / airtable.js

Airtable javascript client
MIT License
1.97k stars 400 forks source link

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

Open bernatfortet opened 11 months ago

bernatfortet commented 11 months ago

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 https://github.com/Airtable/airtable.js/issues/205, https://github.com/Airtable/airtable.js/issues/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 commented 11 months ago

@bendaly818 did you have the same issue?

vinayman commented 11 months ago

I have the same issue @bernatfortet

vinayman commented 11 months ago

@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 commented 11 months ago

Done: https://github.com/Airtable/airtable.js/pull/388

Khaan25 commented 10 months ago

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

Khaan25 commented 10 months ago

@bernatfortet Do you have any current workaround for it?

Khaan25 commented 10 months ago

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 commented 8 months ago

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

experimental: {
    serverMinification: false,
  },
bernatfortet commented 7 months ago

@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 commented 6 months ago

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

clawrence121 commented 5 months ago

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

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 commented 5 months ago

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 commented 5 months ago

Commenting for exposure, same issue with AbortController