invertase / dart_edge Goto Github PK
View Code? Open in Web Editor NEWRun Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
Home Page: https://docs.dartedge.dev
License: Apache License 2.0
Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
Home Page: https://docs.dartedge.dev
License: Apache License 2.0
I tried your library for a start,
I ran this command
edge new supabase_functions new_project
cd new_project
dart pub get
supabase init
edge build supabase_functions --dev
Error
Compilation of the Dart entry file failed:
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/fetch.dart:377:55:
Warning: Initializers for parameters are ignored on static interop external functions.
external static Response redirect(String url, [int? status = 302]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/dom.dart:1835:36:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory Text._([String? data = '']);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/dom.dart:1992:39:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory Comment._([String? data = '']);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1173:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1205:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1237:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1270:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1302:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1334:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1366:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1398:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/encoding.dart:80:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? label = 'utf-8', TextDecoderOptions? options]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/encoding.dart:147:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? label = 'utf-8', TextDecoderOptions? options]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webrtc.dart:2200:59:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory RTCError._(RTCErrorInit init, [String? message = '']);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webidl.dart:26:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '', String? name = 'Error']);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webidl.dart:26:38:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '', String? name = 'Error']);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:43:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:44:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:45:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic z = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:46:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic w = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:93:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:94:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:95:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic z = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:96:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic w = 1]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:175:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:176:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:177:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic width = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:178:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic height = 0]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:224:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:225:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:226:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic width = 0,
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:227:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic height = 0]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/compute_pressure.dart:77:48:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<PressureSource> get supportedSources;
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/performance_timeline.dart:66:40:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<String> get supportedEntryTypes;
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/mediacapture_streams.dart:767:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '']);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/notifications.dart:50:46:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static NotificationPermission get permission;
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/notifications.dart:52:27:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static int get maxActions;
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/websockets.dart:48:53:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory WebSocket._(String url, [dynamic protocols = const []]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/push_api.dart:47:40:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<String> get supportedContentEncodings;
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webusb.dart:210:13:
Warning: Initializers for parameters are ignored on static interop external functions.
[int? bytesWritten = 0]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webusb.dart:288:13:
Warning: Initializers for parameters are ignored on static interop external functions.
[int? bytesWritten = 0]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/media_source_2.dart:101:28:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static bool get canConstructInDedicatedWorker;
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:597:64:
Warning: Initializers for parameters are ignored on static interop external functions.
external static IDBKeyRange lowerBound(dynamic lower, [bool? open = false]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:598:64:
Warning: Initializers for parameters are ignored on static interop external functions.
external static IDBKeyRange upperBound(dynamic upper, [bool? open = false]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:600:14:
Warning: Initializers for parameters are ignored on static interop external functions.
[bool? lowerOpen = false, bool? upperOpen = false]);
^
../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:600:39:
Warning: Initializers for parameters are ignored on static interop external functions.
[bool? lowerOpen = false, bool? upperOpen = false]);
^
Error: Compilation failed.
By default no config is required when developing and deploying, however providing such a file would allow the CLI to hook onto various options:
lib/admin.dart
could deploy as it's own standalone function. Currently, only a single entrypoint is supported.In Supabase functions Request.body
cannot be read ever.
Taking this as a base example it always return "Body not used
" (independently if you send body in your post request or not:
Example cURL:
curl -X POST -d '{"message":"This is a test"}' http://localhost:54321/functions/v1/dart_edge
main.dart
import 'package:supabase_functions/supabase_functions.dart';
void main() {
SupabaseFunctions(fetch: (request) {
if (request.bodyUsed) {
return Response("Body used! - Contents: ${request.body}");
} else {
return Response("Body not used");
}
});
}
If you try to read the body directly there is an error:
import 'package:supabase_functions/supabase_functions.dart';
void main() {
SupabaseFunctions(fetch: (request) {
if (request.body != null) { // accesing body directly
return Response("Body used! - Contents: ${request.body}");
} else {
return Response("Body not used");
}
});
}
UnknownJsTypeError {
"__js_helper$_message": "ReadableStream is locked.",
"$thrownJsError": TypeError: ReadableStream is locked.
at setUpReadableStreamDefaultReader (internal:ext/web/06_streams.js:3357:13)
at new ReadableStreamDefaultReader (internal:ext/web/06_streams.js:4933:7)
at acquireReadableStreamDefaultReader (internal:ext/web/06_streams.js:297:12)
at ReadableStream.getReader (internal:ext/web/06_streams.js:4781:16)
at Request.get$body (file:///home/deno/functions/dart_edge/main.dart.js:7414:89)
at main_closure.call$1 (file:///home/deno/functions/dart_edge/main.dart.js:7424:68)
at file:///home/deno/functions/dart_edge/main.dart.js:7466:60
at _wrapJsFunctionForAsync_closure.$protected (file:///home/deno/functions/dart_edge/main.dart.js:2948:15)
at _wrapJsFunctionForAsync_closure.call$2 (file:///home/deno/functions/dart_edge/main.dart.js:5575:12)
at Object._asyncStartSync (file:///home/deno/functions/dart_edge/main.dart.js:2912:20)
}
I have fallowed the docs of superbase to run dart edge in superbase platform. but even hello world function also not working
doc: https://supabase.com/docs/guides/functions/dart-edge
Support for Firebase or GCP cloud functions would be incredible. A lot of developers use Firebase as their preferred BaaS.
Happy to assist should someone be able to point me in the right direction.
Describe the bug
The SupabaseClient
constructor throws "Cannot create a client without dart:html or dart:io."
error when used in Supabase Dart Edge functions with the supabase_functions package.
An error message looks like the following:
[Error] ub {
a: "Cannot create a client without dart:html or dart:io.",
"$thrownJsError": Unsupported operation: Cannot create a client without dart:html or dart:io.
at Object.J (file:///home/deno/functions/dart_edge/main.dart.js:246:3)
at Object.v (file:///home/deno/functions/dart_edge/main.dart.js:253:14)
at Object.wV (file:///home/deno/functions/dart_edge/main.dart.js:2861:15)
at Object.e2 (file:///home/deno/functions/dart_edge/main.dart.js:2859:14)
at Object.Xa (file:///home/deno/functions/dart_edge/main.dart.js:2685:3)
at e.$1 (file:///home/deno/functions/dart_edge/main.dart.js:5492:8)
at file:///home/deno/functions/dart_edge/main.dart.js:5516:19
at Gs.a (file:///home/deno/functions/dart_edge/main.dart.js:1401:63)
at Gs.$2 (file:///home/deno/functions/dart_edge/main.dart.js:3545:14)
at Object.DI (file:///home/deno/functions/dart_edge/main.dart.js:1381:11)
}
To Reproduce
main.dart
:
import 'package:edge_http_client/edge_http_client.dart';
import 'package:supabase/supabase.dart';
import 'package:supabase_functions/supabase_functions.dart';
void main() {
SupabaseFunctions(fetch: (request) {
final supabaseUrl = Deno.env.get('SUPABASE_URL')!;
final supabaseKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!;
// This SupabaseClient constructor throws an error:
SupabaseClient(
supabaseUrl,
supabaseKey,
httpClient: EdgeHttpClient(),
);
return Response('OK');
});
}
pubspec.yaml
:
name: supabase_flutter_test
description: A sample command-line application.
version: 1.0.0
environment:
sdk: ^3.0.6
dependencies:
edge_http_client: ^0.0.1+3
supabase: 1.11.9
supabase_functions: 0.0.2+4
dev_dependencies:
lints: ^2.0.0
Steps to reproduce the behavior:
dart_edge
function using Postman/curl/etc.Internal Server Error
response and an error message in the functions console.Version:
supabase_flutter_test 1.0.0
├── supabase 1.11.9
│ ├── functions_client 1.3.2
│ ├── gotrue 1.12.4
│ ├── postgrest 1.5.1
│ ├── realtime_client 1.3.0
│ ├── storage_client 1.5.3
└── supabase_functions 0.0.2+4
Additional context
flutter doctor
output:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.5 22G74 darwin-arm64, locale en-UA)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Community Edition (version 2023.1.4)
[✓] VS Code (version 1.82.2)
[✓] Connected device (2 available)
[✓] Network resources
! Doctor found issues in 1 category.
Since I found the project recently we are on Dart 3.3 but I got a lot of errors without changing anything, then tried to updated some version on pubspec.yaml but nothing changed on errors:
I followed dart pub site instructions for Cloudflare Workers, everything worked fine til I asked to build:
⚡ dart run edge build cloudflare_workers --dev
Building package executable... (2.3s)
Built edge:edge.
Compilation of the Dart entry file failed:
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/fetch.dart:377:55:
Warning: Initializers for parameters are ignored on static interop external functions.
external static Response redirect(String url, [int? status = 302]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/dom.dart:1835:36:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory Text._([String? data = '']);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/dom.dart:1992:39:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory Comment._([String? data = '']);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1173:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1205:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1237:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1270:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1302:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1334:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1366:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1398:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/encoding.dart:80:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? label = 'utf-8', TextDecoderOptions? options]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/encoding.dart:147:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? label = 'utf-8', TextDecoderOptions? options]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webrtc.dart:2200:59:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory RTCError._(RTCErrorInit init, [String? message = '']);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webidl.dart:26:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '', String? name = 'Error']);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webidl.dart:26:38:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '', String? name = 'Error']);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:43:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:44:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:45:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic z = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:46:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic w = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:93:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:94:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:95:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic z = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:96:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic w = 1]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:175:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:176:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:177:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic width = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:178:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic height = 0]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:224:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:225:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:226:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic width = 0,
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:227:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic height = 0]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/compute_pressure.dart:77:48:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<PressureSource> get supportedSources;
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/performance_timeline.dart:66:40:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<String> get supportedEntryTypes;
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/mediacapture_streams.dart:767:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '']);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/notifications.dart:50:46:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static NotificationPermission get permission;
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/notifications.dart:52:27:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static int get maxActions;
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/websockets.dart:48:53:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory WebSocket._(String url, [dynamic protocols = const []]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/push_api.dart:47:40:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<String> get supportedContentEncodings;
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webusb.dart:210:13:
Warning: Initializers for parameters are ignored on static interop external functions.
[int? bytesWritten = 0]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webusb.dart:288:13:
Warning: Initializers for parameters are ignored on static interop external functions.
[int? bytesWritten = 0]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/media_source_2.dart:101:28:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static bool get canConstructInDedicatedWorker;
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:597:64:
Warning: Initializers for parameters are ignored on static interop external functions.
external static IDBKeyRange lowerBound(dynamic lower, [bool? open = false]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:598:64:
Warning: Initializers for parameters are ignored on static interop external functions.
external static IDBKeyRange upperBound(dynamic upper, [bool? open = false]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:600:14:
Warning: Initializers for parameters are ignored on static interop external functions.
[bool? lowerOpen = false, bool? upperOpen = false]);
^
../../../../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:600:39:
Warning: Initializers for parameters are ignored on static interop external functions.
[bool? lowerOpen = false, bool? upperOpen = false]);
^
Error: Compilation failed.
I'm using Sonoma.
Since I found this project very promising I'm to help fix any issue if possible. Thank you.
Just some things I've noticed when using the template;
publish_to: none
by default.vercel
in itNetlify offers an integration integartions to work with the Netlify CLI. We've got a package setup to handle this integration but it needs some love. There's a few things to figure out:
Netlify CLI first scans for generated functions, and then runs the provided build command. This means it first starts with no functions, or old ones & serves them. Once that's complete, it then runs the compiler, detects a new function and reloads. This causes a bit of a janky developer experience.
Another issue seems to be that Netlify isn't detecting file changes from a process, and thus doesn't reload the server. Manually saving the file triggers a build, so need to investigate what's going on there.
Randomly when executing a function cold, it will throw this error. I do not seem to see this error after a function is warmed, but if it goes cold and requires first boot again, this is sometimes thrown. Very hard to track from my end, but seems something is being called before everything is fully loaded into memory in some situations?
An error occurred: NoSuchMethodError: method not found: 'constructor' on null
Looks like request.cf
property does not expose ipAddress
.
Fix would be to do request.headers['cf-connecting-ip']
instead.
While accessing non existing kv keys, currently it's throwing an error.
Unhandled Promise Rejection: Error: TypeError: null: type 'JSNull' is not a subtype of type 'FutureOr<String>'
I'm no expert in these, but a better idea would be to make the return type of get
from kvNamespace from Future<String>
to Future<String?>
. Then we can check if the key exists by checking if the value is null.
and when i run exact command in teriminal it's working fine
dart compile js -O4 --no-frequency-based-minification --server-mode -o /home/rr-reddy/StudioProjects/milkman_edge_project/supabase/functions/task1/main.dart.js /home/rr-reddy/StudioProjects/milkman_edge_project/lib/task1.dart
serving edge functions in supabase is also not wokring
Small workaround is adding dart command with full path as below ( line no: 7)
Sample function compiles fine on stable channel but throws error on beta channel. I am assuming this should be fixed before it reaches stable.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 3.13.0-0.2.pre, on macOS 13.4 22F66 darwin-arm64, locale en-TR)
⠹ Compiling 1 functions... (1.8s)Compilation of the Dart entry file failed:
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/fetch.dart:377:55:
Warning: Initializers for parameters are ignored on static interop external functions.
external static Response redirect(String url, [int? status = 302]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/dom.dart:1835:36:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory Text._([String? data = '']);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/dom.dart:1992:39:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory Comment._([String? data = '']);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1173:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1205:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1237:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1270:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1302:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1334:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1366:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/css_typed_om_1.dart:1398:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[dynamic alpha = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/encoding.dart:80:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? label = 'utf-8', TextDecoderOptions? options]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/encoding.dart:147:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? label = 'utf-8', TextDecoderOptions? options]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webrtc.dart:2200:59:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory RTCError._(RTCErrorInit init, [String? message = '']);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webidl.dart:26:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '', String? name = 'Error']);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webidl.dart:26:38:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '', String? name = 'Error']);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:43:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:44:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:45:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic z = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:46:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic w = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:93:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:94:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:95:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic z = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:96:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic w = 1]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:175:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:176:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:177:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic width = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:178:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic height = 0]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:224:35:
Warning: Initializers for parameters are ignored on static interop external functions.
[/* double | NaN */ dynamic x = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:225:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic y = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:226:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic width = 0,
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/geometry_1.dart:227:34:
Warning: Initializers for parameters are ignored on static interop external functions.
/* double | NaN */ dynamic height = 0]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/compute_pressure.dart:77:48:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<PressureSource> get supportedSources;
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/performance_timeline.dart:66:40:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<String> get supportedEntryTypes;
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/mediacapture_streams.dart:767:16:
Warning: Initializers for parameters are ignored on static interop external functions.
[String? message = '']);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/notifications.dart:50:46:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static NotificationPermission get permission;
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/notifications.dart:52:27:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static int get maxActions;
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/websockets.dart:48:53:
Warning: Initializers for parameters are ignored on static interop external functions.
external factory WebSocket._(String url, [dynamic protocols = const []]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/push_api.dart:47:40:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static Iterable<String> get supportedContentEncodings;
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webusb.dart:210:13:
Warning: Initializers for parameters are ignored on static interop external functions.
[int? bytesWritten = 0]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/webusb.dart:288:13:
Warning: Initializers for parameters are ignored on static interop external functions.
[int? bytesWritten = 0]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/media_source_2.dart:101:28:
Error: External extension members with the keyword 'static' on JS interop and @Native types are disallowed.
external static bool get canConstructInDedicatedWorker;
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:597:64:
Warning: Initializers for parameters are ignored on static interop external functions.
external static IDBKeyRange lowerBound(dynamic lower, [bool? open = false]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:598:64:
Warning: Initializers for parameters are ignored on static interop external functions.
external static IDBKeyRange upperBound(dynamic upper, [bool? open = false]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:600:14:
Warning: Initializers for parameters are ignored on static interop external functions.
[bool? lowerOpen = false, bool? upperOpen = false]);
^
../../../../.pub-cache/hosted/pub.dev/js_bindings-0.1.2+2/lib/bindings/indexeddb_3.dart:600:39:
Warning: Initializers for parameters are ignored on static interop external functions.
[bool? lowerOpen = false, bool? upperOpen = false]);
^
Error: Compilation failed.
const testEnvVar = String.fromEnvironment(
'SUPABASE_URL',
defaultValue: 'defaultVal',
);
The env var SUPABASE_URL comes built in as a default secret, per https://supabase.com/docs/guides/functions/secrets, yet defaultVal is returned.
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:
UnsupportedError {
message: "Cannot create a client without dart:html or dart:io.",
"$thrownJsError": Unsupported operation: Cannot create a client without dart:html or dart:io.
at Object.wrapException (file:///home/deno/functions/dart_edge/main.dart.js:1051:17)
at Object.throwExpression (file:///home/deno/functions/dart_edge/main.dart.js:1065:15)
at Object.createClient (file:///home/deno/functions/dart_edge/main.dart.js:11473:16)
at file:///home/deno/functions/dart_edge/main.dart.js:7067:44
at _wrapJsFunctionForAsync_closure.$protected (file:///home/deno/functions/dart_edge/main.dart.js:3609:15)
at _wrapJsFunctionForAsync_closure.call$2 (file:///home/deno/functions/dart_edge/main.dart.js:14042:12)
at Object._asyncStartSync (file:///home/deno/functions/dart_edge/main.dart.js:3573:20)
at Object._withClient$body (file:///home/deno/functions/dart_edge/main.dart.js:7103:16)
at Object._withClient (file:///home/deno/functions/dart_edge/main.dart.js:7050:16)
at Object.get (file:///home/deno/functions/dart_edge/main.dart.js:7047:16)
}
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<String, dynamic>?;
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.
The fetch
API is very much a JavaScript concept, so for Dart developers it might be a bit confusing and not intuitive to use. It's most likely they'll reach for a library such as dio
or http
, however these all use the underlying XMLHttpRequest interface which isn't available on edge runtimes.
In theory, we can use a HttpOverride which internally uses the fetch
API, and attach this as an override when using a provider. Then all Dart HTTP libraries should work as expected via the fetch
API.
How to use it in Docker
I've browsed around but I'm not sure to understand how it is intended to be used to use multiple functions. Do we need one dart project for each function ?
js_bindings
is extensively used throughout the repo, but it's discontinued in favour of typings
.
Typings also has Deno bindings generated so a lot of code is not needed anymore.
The runBuild
method is empty. I'm not sure but shouldn't it be something like
Future<void> runBuild() async {
final functionDirectory = Directory(
p.join(Directory.current.path, 'supabase', 'functions', 'dart_edge'),
);
final compiler = Compiler(
logger: logger,
entryPoint: p.join(Directory.current.path, 'lib', 'main.dart'),
outputDirectory: functionDirectory.path,
outputFileName: 'main.dart.js',
level: CompilerLevel.O1,
);
await compiler.compile();
}
Plain print()
calls now generate INFO messages on Supabase.
How can we implement a full logging system with different logging levels?
pubspec.yaml:
environment:
sdk: ">=2.18.5 <3.0.0"
dependencies:
edge: ^0.0.6
edge_http_client: ^0.0.1+1
supabase: ^1.6.3
supabase_functions: ^0.0.1+1
dependency_overrides:
edge:
git:
url: https://github.com/invertase/dart_edge.git
ref: main
path: packages/edge
supabase_functions:
git:
url: https://github.com/invertase/dart_edge.git
ref: main
path: packages/supabase_functions
I can not make a build with the command edge build supabase_functions
after the recent fix still
Reproduction:
void main() {
cf.CloudflareWorkers(fetch: (request, env, ctx) async {
return cf.Response.json({});
});
}
Logs:
✘ [ERROR] Uncaught (in response) Error: [object Object]
✘ [ERROR] Uncaught (in promise) UnknownJsTypeError
Not sure if misunderstanding the API though, it's typed as Object?
however with no code docs so not clear what it should be? Even Response.json("{}")
errors
Custom headers are not being passed through the exposed fetch function.
import 'dart:convert';
import 'package:cloudflare_workers/cloudflare_workers.dart';
import 'package:intl/intl.dart';
void main() async {
final kiwiRepository = KiwiRepository();
CloudflareWorkers(
fetch: (final Request request, final _, final __) async {
if (request.url.toString().contains('favicon.ico')) {
return Response(null);
}
try {
final tickets = await kiwiRepository.fetchTickets();
return Response(jsonEncode(tickets));
} catch (e) {
return Response('Error: $e');
}
},
);
}
class KiwiRepository {
const KiwiRepository();
FutureOr<Map> fetchTickets() async {
final uri = Uri(
scheme: 'https',
host: 'api.tequila.kiwi.com',
path: 'v2/search',
queryParameters: <String, String>{
'fly_from': 'FAT',
'fly_to': 'JFK',
'date_from': DateFormat('dd/MM/yyyy').format(
DateTime.now(),
),
'date_to': DateFormat('dd/MM/yyyy').format(
DateTime.now().add(const Duration(days: 30)),
),
'limit': '25',
'sort': 'price',
},
);
final headers = Headers(
{
'apikey': '****',
},
);
final response = await fetch(
Resource.uri(uri),
headers: headers,
);
final data = await response.json();
return (data as Map<String, dynamic>);
}
}
Can I create a new DART edge project as a sub folder within an existing Flutter project? This is because I want to reuse data model classes already defined in the Flutter project.
Hi,
After following the steps in https://docs.dartedge.dev/platform/supabase I get a Not found message while trying to test the function locally (http://localhost:54321/functions/v1/dart_edge
).
Please add on which version of Flutter/Dart this framework can work on.
Related to #50
Error:
SyntaxError: Unexpected end of JSON input
at parse (<anonymous>)
at packageData (ext:deno_fetch/22_body.js:368:14)
at consumeBody (ext:deno_fetch/22_body.js:245:12)
at eventLoopTick (ext:core/01_core.js:172:13)
Example:
import 'dart:convert';
import 'package:supabase_functions/supabase_functions.dart' as edge;
void main() {
edge.SupabaseFunctions(fetch: (request) async {
final data = await request.json();
print(data);
return edge.Response(
json.encode({'message': 'Message created!', 'id': 'a'}),
status: 200,
headers: edge.Headers({
'Content-Type': 'application/json',
}),
);
});
}
When attempting to get the data included with a request payload I see this. I have not been able to find a way to properly receive the json from the request.
Vercel has recently added its own suite of managed, serverless storage products:
It would be nice if Dart Edge supported these new APIs, to assist developers who want to build Vercel applications with Dart Edge.
Executing this:
supabase functions deploy dart_edge --debug
Getting this:
Supabase CLI 1.110.1
Version 1.30.3 is already installed
Bundling dart_edge
Error bundling function: exit status 1
file:///Users/andrey/Documents/MyProjects/Pillarium/pillarium_edge/supabase/functions/import_map.json
file:///Users/andrey/Documents/MyProjects/Pillarium/pillarium_edge/supabase/functions/dart_edge/index.ts
error: Uncaught (in promise) Error: NotFound: No such file or directory (os error 2)
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/[email protected]/eszip_wasm.generated.js:513:19)
at <anonymous> (https://deno.land/x/[email protected]/eszip_wasm_bg.wasm:1:1559899)
at <anonymous> (https://deno.land/x/[email protected]/eszip_wasm_bg.wasm:1:1398157)
at <anonymous> (https://deno.land/x/[email protected]/eszip_wasm_bg.wasm:1:1895031)
at __wbg_adapter_40 (https://deno.land/x/[email protected]/eszip_wasm.generated.js:229:6)
at real (https://deno.land/x/[email protected]/eszip_wasm.generated.js:213:14)
Hey guys, loving this package in the edge function. but any plans to add muliPartRequest to the package?
I've deployed this after compiling it with edge build supabase_functions --dev
as the main isn't working.
However , I expected to get all the query params with the following call:
import 'package:edge/edge.dart';
import 'package:supabase_functions/supabase_functions.dart';
void main() {
SupabaseFunctions(fetch: (request) async {
final text = request.url.queryParameters['text'] ?? 'Hello, world!';
final height = request.url.queryParameters['height'] ?? '630';
final length = request.url.queryParameters['length'] ?? '1200';
final pattern = request.url.queryParameters['pattern'] ?? '';
final pcolor = request.url.queryParameters['pcolor'] ?? '#040703';
final scolor = request.url.queryParameters['scolor'] ?? '#055C13';
final text_color = request.url.queryParameters['text_color'] ?? '#FFFFFF';
final svg = generateOGImage(text, int.parse(height), int.parse(length), pattern, pcolor, scolor, text_color);
final headers = Headers({'Content-Type': 'text/plain', 'Cache-Control': 'public, max-age=3600'});
String all_query_string = 'Text: $text \nHeight: $height \nLength: $length \nPattern: $pattern \nPrimary Color: $pcolor \nSecondary Color: $scolor \nText Color: $text_color';
return Response(utf8.encode(all_query_string),
status: 200,
headers: headers
);
});
}
For example a call to:
Should return:
Text: Generate images with dart edge
Height: 630
Length: 1200
Pattern: surf
Primary Color: #040703
Secondary Color: #FFFFFF
Text Color: #FF0000
I get the following:
Text: Hello, world!
Height: 630
Length: 1200
Pattern: surf
Primary Color: #040703
Secondary Color:
Text Color: #FFFFFF
Expected results:
Text: generate images with dart edge
Height: 800
Length: 1200
Pattern: surf
Primary Color: #100000
Secondary Color: #FFF
Text Color: #FF0000
Actual results:
Text: generate images with dart edge
Height: 800
Length: 1200
Pattern: surf
Primary Color:
Secondary Color: #055C13
Text Color: #FFFFFF
Hi,
I can send an email using SMTP in Typescript.
import { SMTPClient } from "https://deno.land/x/denomailer/mod.ts";
....
const smtp = new SMTPClient({
connection: {
hostname: Deno.env.get('_SMTP_HOSTNAME')!,
port: Number(Deno.env.get('_SMTP_PORT')!),
tls: true,
auth: {
username: Deno.env.get('_SMTP_USERNAME')!,
password: Deno.env.get('_SMTP_PASSWORD')!,
},
},
});
...
await smtp.send({ ....})
However I would prefer to use Dart on the Edge functions.
I tried to use the mailer library but it doesn't work. issue
What is the best way to achieve this?
I can't seem to find a solution in the web, which is weird because I thought it would be a usual feature.
Am I overlooking something?
Thank you for any tips
Error:
Error: Dart library 'dart:html' is not available on this platform.
import 'dart:html' show Blob, FormData, UrlSearchParams;
^
Info: The unavailable library 'dart:html' is imported through these packages:
package:supabase_edge_functions_example => package:dart_openai => package:fetch_client => package:fetch_api => dart:html
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
import 'package:supabase_functions/supabase_functions.dart';
import 'package:fetch_api/fetch_api.dart' as api;
void main() {
SupabaseFunctions(fetch: (request) {
void main() async {
// Simple cors request
final response = await fetch(
Resource('https://api.restful-api.dev/objects/1'),
);
print(await response.text());
}
return Response("Hello from Supabase Edge Functions!");
});
}
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:
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
import 'package:dart_openai/src/core/utils/http_client_io.dart'
if (dart.library.js) 'package:dart_openai/src/core/utils/http_client_web.dart'
if (dart.library.io) 'package:dart_openai/src/core/utils/http_client_io.dart';
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.
const response = await options.runtime.dispatchFetch(String(getURL(req)), {
^
TypeError: options.runtime.dispatchFetch is not a function
at Server.handler (/<path>/.npm/_npx/e04f8f8c002b5887/node_modules/edge-runtime/dist/server/create-handler.js:28:56)
at Server.emit (node:events:513:28)
at parserOnIncoming (node:_http_server:1091:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
Node.js v18.16.0
I tried to use this library: https://pub.dev/packages/http but it gives me an error. What else I can use?
After generating my edge function, I received
error: Uncaught TypeError: Cannot read properties of undefined (reading 'toString')
t1.toString;
t1 = A._asStringQ(self.Deno.env.get("OPENAI_API_KEY"));
t1.toString;
I'm not sure if the code generation is directly handled by dart edge. As you can see, the root of this comes from a Deno.env variable. It may be more proper to always add these to a empty string. The issue is fixed after removing
t1.toString;
I think this happens because of the way this library maps the String value to the OpenAI type --
OpenAI.apiKey = edge.Deno.env.get('OPENAI_API_KEY')!;
the occurrence of this convention might be rare, but this issue will at minimum serve to help others know they can simply remove the .toString from generated code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.