-
Notifications
You must be signed in to change notification settings - Fork 24
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
Error: Dart library 'dart:html' is not available on this platform. #32
Comments
Unfortunately the Zekfad/fetch_api package is assuming the user is running on the web environment, not a JS one. I'll take a look at the openai package but I'm not sure there's much we can do. |
Hmm, replacing this: fetch.FetchClient createClient() =>
fetch.FetchClient(mode: fetch.RequestMode.cors); with import 'package:edge_http_client/edge_http_client.dart';
http.Client createClient() => EdgeHttpClient(); Could do the trick. |
The problem is that the code execution follows the JS path for building edge functions, if it followed the normal io path it seems your override would work. If I remove the web dependency from the lib the edge function compiles fine. |
After forcing the import path, or modifying the package to use
as suggested, I now see the same issue as in #34. Will close this to resolve there. |
Error:
Any edge function that references packages that nest dart:html should trigger this.
https://github.com/anasfik/openai
uses
https://github.com/Zekfad/fetch_client
uses
https://github.com/Zekfad/fetch_api
Example:
create new edge function
dart pub add fetch_api
This all makes sense in that dart_edge has created a custom fetch client, but some packages use custom fetch clients as well. I am attempted to get the dart_openai package to work, which uses conditional importing of the referenced fetch package here:
https://github.com/anasfik/openai/blob/aa42ccee89c0fef5b4102eceee11d28890d0bcdb/lib/src/core/networking/client.dart
if I remove the conditional import so that it only sees the http_client_io, the package will compile as an edge function. If the conditional import is present based on dart.library.io, or even refactoring the imports to look like this
I run into the error referenced above as the import takes the web path. I am not sure if this is directly a dart_edge issue, but thought I would start here as it is likely similar imports / nesting of dart:html will be found across the package ecosystem.
The text was updated successfully, but these errors were encountered: