supabase / edge-runtime

A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services.
MIT License
673 stars 62 forks source link

event loop error: Error: unreachable #282

Closed nietsmmar closed 8 months ago

nietsmmar commented 8 months ago

Bug report

Describe the bug

When importing npm:@azure/openai@1.0.0-beta.11 through my import_map I get this error:

Error: unreachable
    at arch (ext:deno_node/_process/process.ts:16:11)
    at get arch [as arch] (node:process:301:14)
    at Object.arch (node:os:35:18)
    at setPlatformSpecificData (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:542:37)
    at getUserAgentValue (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:572:5)
    at userAgentPolicy (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:591:28)
    at Object.createPipelineFromOptions (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:1826:24)
    at createDefaultPipeline (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure-rest/core-client/1.2.0/dist/index.js:107:39)
    at getClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure-rest/core-client/1.2.0/dist/index.js:436:22)
    at createClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/openai/1.0.0-beta.11/dist-esm/src/rest/openAIClient.js:35:20)
runtime has escaped from the event loop unexpectedly: Error: unreachable
    at arch (ext:deno_node/_process/process.ts:16:11)
    at get arch [as arch] (node:process:301:14)
    at Object.arch (node:os:35:18)
    at setPlatformSpecificData (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:542:37)
    at getUserAgentValue (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:572:5)
    at userAgentPolicy (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:591:28)
    at Object.createPipelineFromOptions (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:1826:24)
    at createDefaultPipeline (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure-rest/core-client/1.2.0/dist/index.js:107:39)
    at getClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure-rest/core-client/1.2.0/dist/index.js:436:22)
    at createClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/openai/1.0.0-beta.11/dist-esm/src/rest/openAIClient.js:35:20)
failed to send request to user worker: connection error: Connection reset by peer (os error 104)
user worker failed to respond: connection error: Connection reset by peer (os error 104)
InvalidWorkerResponse: user worker failed to respond
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:76:21)
    at async Server.<anonymous> (file:///home/deno/main/index.ts:146:12)
    at async #respond (https://deno.land/std@0.182.0/http/server.ts:220:18) {
  name: "InvalidWorkerResponse"
}

deployed it looks like this in the logs:

event loop error: Error: unreachable
    at arch (ext:deno_node/_process/process.ts:16:11)
    at get arch [as arch] (node:process:275:14)
    at Object.arch (node:os:36:18)
    at setPlatformSpecificData (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:542:37)
    at getUserAgentValue (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:572:5)
    at userAgentPolicy (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:591:28)
    at Object.createPipelineFromOptions (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/core-rest-pipeline/1.14.0/dist/index.js:1826:24)
    at createDefaultPipeline (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure-rest/core-client/1.2.0/dist/index.js:107:39)
    at getClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure-rest/core-client/1.2.0/dist/index.js:436:22)
    at createClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@azure/openai/1.0.0-beta.11/dist-esm/src/rest/openAIClient.js:35:20)

To Reproduce

add "azureai": "npm:@azure/openai@1.0.0-beta.11" to your import_map and use it like this:

import { OpenAIClient, AzureKeyCredential } from "azureai";

export const azureOpenAi = new OpenAIClient(
  "MY_URL", 
  new AzureKeyCredential(Deno.env.get('AZURE_OPENAI_API_KEY'))
);

Expected behavior

Being able to use the lib.

System information

Additional context

It happens in local edge functions as well as deployed.

laktek commented 8 months ago

@nietsmmar Are you serving Edge Functions via Supabase CLI? If so, can you try upgrading the Supabase CLI to the latest?

nietsmmar commented 8 months ago

@laktek I am using the latest (available) for manjaro, which is not the latest. But as stated in my post I am having the problem also when having my edge-function deployed.

I logged the Deno.version and it gave me: supabase-edge-runtime-1.33.5 (compatible with Deno v1.39.2)

laktek commented 8 months ago

@nietsmmar Ah gotcha! I have deployed a newer version of edge-runtime to Supabase production. Can you check if you still experience the same issue?

nietsmmar commented 8 months ago

@laktek Nice!! now it works. Thank you so much.

laktek commented 8 months ago

Good to hear it's working! Will close this issue.