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

First parameter has member 'readable' that is not a ReadableStream #62

Closed
Gbuomprisco opened this issue Oct 25, 2023 · 18 comments
Closed

Comments

@Gbuomprisco
Copy link

Hi there,

The Remix apps (mine and my customers') have stopped working quite out of the blue.

Remix version: 2.0.1 to 2.1.0
Node: v18

This cannot be reproduced locally.

See the below error:

Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: First parameter has member 'readable' that is not a ReadableStream.","reason":{"errorType":"TypeError","errorMessage":"First parameter has member 'readable' that is not a ReadableStream.","stack":["TypeError: First parameter has member 'readable' that is not a ReadableStream.","    at assertReadableStream (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:362:19)","    at convertReadableWritablePair (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:3524:9)","    at ReadableStream.pipeThrough (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:3608:29)","    at fetchFinale (node:internal/deps/undici/undici:11082:56)","    at mainFetch (node:internal/deps/undici/undici:10974:9)","    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: First parameter has member 'readable' that is not a ReadableStream.","    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)","    at process.emit (node:events:529:35)","    at process.emit (node:domain:489:12)","    at emit (node:internal/process/promises:149:20)","    at processPromiseRejections (node:internal/process/promises:283:27)","    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
Unknown application error occurred
Runtime.Unknown

Happy to provide any more details that could help debug this, I am not sure right now what could be of help!

@TooTallNate
Copy link
Member

Can you provide a repro repository?

@leeuwis
Copy link

leeuwis commented Oct 25, 2023

Same thing is happening to our applications, also seemed to happen out of the blue

@reisr3
Copy link

reisr3 commented Oct 25, 2023

Same here - all deployments failing, when they were passing fine yesterday.

@andreslemusm
Copy link

andreslemusm commented Oct 25, 2023

same here:

Unhandled Promise Rejection

{
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "TypeError: First parameter has member 'readable' that is not a ReadableStream.",
  "reason": {
    "errorType": "TypeError",
    "errorMessage": "First parameter has member 'readable' that is not a ReadableStream.",
    "stack": [
      "TypeError: First parameter has member 'readable' that is not a ReadableStream.",
      "    at assertReadableStream (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:362:19)",
      "    at convertReadableWritablePair (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:3524:9)",
      "    at ReadableStream.pipeThrough (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:3608:29)",
      "    at fetchFinale (node:internal/deps/undici/undici:11082:56)",
      "    at mainFetch (node:internal/deps/undici/undici:10974:9)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
    ]
  },
  "promise": {},
  "stack": [
    "Runtime.UnhandledPromiseRejection: TypeError: First parameter has member 'readable' that is not a ReadableStream.",
    "    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)",
    "    at process.emit (node:events:529:35)",
    "    at process.emit (node:domain:489:12)",
    "    at emit (node:internal/process/promises:149:20)",
    "    at processPromiseRejections (node:internal/process/promises:283:27)",
    "    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
  ]
}

Unknown application error occurred
Runtime.Unknown

@emma-sg
Copy link

emma-sg commented Oct 25, 2023

Minimal reproduction, based off of Vercel's Remix boilerplate repo: https://github.com/emma-sg/remix-boilerplate

@andreslemusm
Copy link

Referencing this other issue on the remix repo, not sure if it would help debugging/solving this issue

@TooTallNate
Copy link
Member

Thanks for the repro. We are investigating.

@TooTallNate
Copy link
Member

Sorry about that folks. This should be fixed now. You will need to re-deploy your project.

@baberMatt
Copy link

baberMatt commented Nov 28, 2023

I see a fix was pushed a month ago, however I'm running into this error on my remix deployment.

I've build the app to work with convex.dev, specifically their HttpClient

All remix app routes on vercel that have a loader or action that uses this HttpClient result in the error from the OP. What interesting is await convex call does resolve and logs expected results server side but the error in question is thrown right after and crashes the app?

export async function loader() {
  try {
    const convex = new ConvexHttpClient(process.env.CONVEX_URL ?? "");
    const features = await convex.query(api.features.getFeatures);
    console.log("features", features);
    return json({ features });
  } catch (error: unknown) {
    if (error instanceof Error) {
      console.error(error.message);
      return json({ error: error.message }, { status: error.message === "User not authenticated" ? 401 : 500 });
    }
    return json({ error: "An unknown error occurred" }, { status: 500 });
  }
}

@TooTallNate
Copy link
Member

@baberMatt Could you create a standalone repo so that we can take a closer look?

@baberMatt
Copy link

@TooTallNate thanks for jumping back in this issue. Below is a stand alone app with README for set up. Expect it to work on local. If you test my deployed app on Vercel you will see the error in action - but to access server logs you'll likely need to run your own deploy. Let me know if you have any questions. Not sure what exposure you have to convex yet but I'd be happy to help with what I know.

Repo

Test Prod

@baberMatt
Copy link

@TooTallNate any update on this by chance. Hoping to deploy this week. I've you think this warrants a new issue I'd be happy to open it.

@ablesense-hugh
Copy link

I met the same issue again when deploy my project to Vercel:

Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: First parameter has member 'readable' that is not a ReadableStream.","reason":{"errorType":"TypeError","errorMessage":"First parameter has member 'readable' that is not a ReadableStream.","stack":["TypeError: First parameter has member 'readable' that is not a ReadableStream."," at assertReadableStream (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:466:19)"," at convertReadableWritablePair (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:4038:9)"," at ReadableStream.pipeThrough (/var/task/node_modules/web-streams-polyfill/dist/ponyfill.js:4122:29)"," at fetchFinale (node:internal/deps/undici/undici:9905:56)"," at mainFetch (node:internal/deps/undici/undici:9794:9)"," at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: First parameter has member 'readable' that is not a ReadableStream."," at process. (file:///var/runtime/index.mjs:1276:17)"," at process.emit (node:events:529:35)"," at emit (node:internal/process/promises:149:20)"," at processPromiseRejections (node:internal/process/promises:283:27)"," at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}

@maxfi
Copy link

maxfi commented Apr 6, 2024

I'm having the same issue with https://github.com/xataio/client-ts/blob/main/packages/client/README.md. As inngest/inngest-js#304 mentions, it seems to be a polyfil issue. How can we workaround this? Thanks. 🙏

UPDATE:
The following works:

import { fetch as webFetch } from "@remix-run/web-fetch";
import { XataClient } from "./xata.server";

export const xata = new XataClient({
  fetch: webFetch,
});

I would have thought that the installGlobals call in my vite.config.ts would have replaced undici with remix's fetch?

import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { vercelPreset } from "@vercel/remix/vite";
import { remixRoutes } from "remix-routes/vite";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

installGlobals();

export default defineConfig({
  plugins: [
    remix({ presets: [vercelPreset()] }),
    tsconfigPaths(),
    remixRoutes({ strict: true }),
  ],
});

Reference: https://discord.com/channels/996791218879086662/1219884837502980168

@nsijwali
Copy link

I'm having the same issue with https://github.com/xataio/client-ts/blob/main/packages/client/README.md. As inngest/inngest-js#304 mentions, it seems to be a polyfil issue. How can we workaround this? Thanks. 🙏

UPDATE: The following works:

import { fetch as webFetch } from "@remix-run/web-fetch";
import { XataClient } from "./xata.server";

export const xata = new XataClient({
  fetch: webFetch,
});

I would have thought that the installGlobals call in my vite.config.ts would have replaced undici with remix's fetch?

import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { vercelPreset } from "@vercel/remix/vite";
import { remixRoutes } from "remix-routes/vite";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

installGlobals();

export default defineConfig({
  plugins: [
    remix({ presets: [vercelPreset()] }),
    tsconfigPaths(),
    remixRoutes({ strict: true }),
  ],
});

Reference: https://discord.com/channels/996791218879086662/1219884837502980168

can you explain this solution

@baberMatt
Copy link

baberMatt commented May 15, 2024

FWIW, I finally got around to triggering a redeploy on my sample app. And the /convex route works. (Defying the defined expectations on home) aka seems fixed.

https://convex-remix-demo.vercel.app/

@wong2
Copy link

wong2 commented May 29, 2024

I still get this error when using AI SDK 3.1 with Remix

The error occurs here: https://github.com/vercel/ai/blob/4d458dfd1806e793b7b14acddb56ff48517b3b41/packages/provider-utils/src/response-handler.ts#L98

@anthonyringoet
Copy link

What fixed it for me: vercel/ai#199 (comment)

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