vercel / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
63 stars 19 forks source link

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

Closed Gbuomprisco closed 1 year ago

Gbuomprisco commented 1 year ago

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 commented 1 year ago

Can you provide a repro repository?

leeuwis commented 1 year ago

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

reisr3 commented 1 year ago

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

andreslemusm commented 1 year ago

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 commented 1 year ago

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

andreslemusm commented 1 year ago

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

TooTallNate commented 1 year ago

Thanks for the repro. We are investigating.

TooTallNate commented 1 year ago

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

baberMatt commented 11 months ago

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

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

baberMatt commented 11 months ago

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

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

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

I'm having the same issue with https://github.com/xataio/client-ts/blob/main/packages/client/README.md. As https://github.com/inngest/inngest-js/issues/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 commented 5 months ago

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

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

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