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

RTKQ: Nextjs getServerSideProps #1240

Closed
romseguy opened this issue Jul 2, 2021 · 7 comments
Closed

RTKQ: Nextjs getServerSideProps #1240

romseguy opened this issue Jul 2, 2021 · 7 comments

Comments

@romseguy
Copy link

romseguy commented Jul 2, 2021

Hello,

As mentioned by @gfortaine here we can avoid the error Expected signal to be an instanceof AbortSignal by using Node 15.

The problem being that Vercel's Node version is 14.x

Is there any workaround until Vercel offers more recent Node versions?

@phryneas
Copy link
Member

You might want to follow #1277 where I'm building SSR support.

For me, I solved this specific problem by doing

const { default: AbortController } = require("abort-controller");
const { default: fetch, Headers, Request, Response } = require("node-fetch");

Object.assign(globalThis, {
  fetch,
  Headers,
  Request,
  Response,
  AbortController,
});

in _app.js

@markerikson
Copy link
Collaborator

markerikson commented Nov 5, 2021

Available in the 1.7 betas.

(Either that or the workaround solves the AbortController question, one of the two.)

@agusterodin
Copy link

Wait does 1.7 beta-1 fix this? I am deploying on Vercel running Node 14.x and still get this issue despite being on 1.7 beta-1.

I also tried adding

const { default: AbortController } = require("abort-controller");
const { default: fetch, Headers, Request, Response } = require("node-fetch");

Object.assign(globalThis, {
  fetch,
  Headers,
  Request,
  Response,
  AbortController,
});

to my _app.tsx file but when testing locally on my M1 MacBook running Node 16.x I get this error

error - node:fs
Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
(node:85648) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
wait  - compiling /_error...
error - node:fs
Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.

@agusterodin
Copy link

^ It also won't compile on vercel either when I try to do the _app trick

@phryneas
Copy link
Member

@agusterodin that is not something we have any control over unfortunately. You'll have to dig into your environment, the fetch polyfills you use and when they are loaded (the sooner the better).

@agusterodin
Copy link

Gotcha, thanks! For anybody else encountering this I will leave this link here:

https://github.com/vercel/vercel/discussions/7003

Node 16 on Vercel seems like it is around the corner.

@srosato
Copy link

srosato commented Dec 8, 2021

I only had this problem when using jest, I ended up doing this under node 14.x within my jest.setup.ts:

import 'isomorphic-fetch'
import { default as AbortController } from "abort-controller"
Object.assign(globalThis, {
    AbortController,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants