Open htsuruo opened 1 year ago
Closed my related issue and wanted to add @HTsuruo's very cool example repository. May be very useful in diagnosing this -- https://github.com/HTsuruo/dart-edge-supabase-playground/tree/main
Thanks for the guide and workaround too 🙏
Maybe an override of dart:html with https://pub.dev/packages/universal_html would work?
If fetch is conforms to browsers' one you may try to use fetch_client, it is independent of io or html, using only js interop to call global fetch function.
Maybe an override of dart:html with https://pub.dev/packages/universal_html would work?
Tried.
root@DESKTOP-IAH5ULT:/mnt/d/src/hackathons/2023/intellitask/functions# npx supabase functions serve dart_edge --no-verify-jwt --env-file ./.env
Serving functions with legacy supabase/deno-relay:v1.6.0... Run functions serve instead to use Edge Runtime.
Starting supabase/functions/dart_edge
Serving supabase/functions/dart_edge
Watcher Process started.
Check file:///home/deno/functions/dart_edge/index.ts
UnsupportedError {
message: "Platform._version",
"$thrownJsError": Unsupported operation: Platform._version
at Object.wrapException (file:///home/deno/functions/dart_edge/main.dart.js:2247:17)
at Object._Platform__version (file:///home/deno/functions/dart_edge/main.dart.js:8509:15)
at Object._Platform_version (file:///home/deno/functions/dart_edge/main.dart.js:8565:16)
at file:///home/deno/functions/dart_edge/main.dart.js:39067:74
at Object.holder.<computed> [as $get$Platform__version] (file:///home/deno/functions/dart_edge/main.dart.js:130:21)
at Object.HttpClient_HttpClient (file:///home/deno/functions/dart_edge/main.dart.js:250:14)
at WindowController_onChooseHttpClient_closure.call$1 (file:///home/deno/functions/dart_edge/main.dart.js:36649:75)
at WindowController.onChooseHttpClient$1 (file:///home/deno/functions/dart_edge/main.dart.js:36642:44)
at file:///home/deno/functions/dart_edge/main.dart.js:36609:48
at _wrapJsFunctionForAsync_closure.$protected (file:///home/deno/functions/dart_edge/main.dart.js:4927:15)
Sounds like the only way to get OpenAI's API to work atm is to call another function which handles the call and just returns the result.
https://supabase.com/docs/reference/javascript/functions-invoke
Which defeats the point of using Dart Edge functions at all, and one may as well just use Deno to begin with.
I am running on Supabase Edge.
As far as I understand from Fetching Data, it is possible to fetch data using two approaches, Fetch and HTTP Package.
However, the sample does not describe how to use it with platforms such as Supabase or Vercel using
http.runWithClient
.When I tried writing the following code, an
UnsupportedError
occurred:Reproducible code
```dart void main() { http.runWithClient(() async { SupabaseFunctions(fetch: (request) async { // Get IP address final response = await http.get( Uri.parse('http://httpbin.org/ip'), headers: {'Content-Type': 'application/json'}, ); if (response.statusCode == 200) { final json = response.body as Map?;
print(json);
return Response.json(json);
}
return Response.error();
});
}, () => EdgeHttpClient());
}
```
Is my usage incorrect? Or is the HTTP package not yet supported in Supabase? It was available with the Fetch API.
I want to use packages like dart_openai | Dart Package, but since their internal implementation depends on
http
, I cannot use them without resolving the above issue.Thanks.