invertase / dart_edge

Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
https://docs.dartedge.dev
Apache License 2.0
324 stars 23 forks source link

fix: cache reader to prevent locking #41

Closed lesnitsky closed 1 year ago

lesnitsky commented 1 year ago

Closes #40

henry2man commented 1 year ago

I've installed edge manually using this branch but I'm still having errors:

Check file:///home/deno/functions/dart_edge/index.ts

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux aarch64
Version: 1.30.3
Args: ["deno", "run", "--no-check=remote", "--allow-all", "--watch", "--no-clear-screen", "--no-npm", "/home/deno/functions/dart_edge/index.ts"]

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /deno/serde_v8/de.rs:630:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Stopped serving supabase/functions/dart_edge

request.bodyUsed is still false, this Panic occurs if I try to check that request.body != null

EDIT: I thought I installed custom edge in a bad way, but I've double checked that even with the patch the issue is still present.

henry2man commented 1 year ago

@lesnitsky did you check the example function I've posted? I think there is an underlying issue

lesnitsky commented 1 year ago

@henry2man yes, I've checked your function and it worked for me. Make sure to make a clean install and build. How did you install dart_edge from there branch?

henry2man commented 1 year ago

These are the exact steps:

dart pub global deactivate edge
git clone git@github.com:invertase/dart_edge.git
git checkout fix/request-body-access
cd dart_edge/packages/edge
dart pub global activate --source path .

Then I've rebuilt and served demo function:

supabase start edge build supabase_functions --dev supabase functions serve dart_edge --no-verify-jwt

lesnitsky commented 1 year ago

I can't see git checkout fix/request-body-access in your steps

henry2man commented 1 year ago

I can't see git checkout fix/request-body-access in your steps

Oh, I forgot to add this. But I'm on the correct branch:

/dart_edge/packages/edge$ git branch
* fix/request-body-access
  main
henry2man commented 1 year ago

Just to add context: I'm on an standard ubuntu server 22.04 instance. Prior to this I've followed this tutorial: https://www.youtube.com/watch?v=53jhgrDONW4

lesnitsky commented 1 year ago

did you also update a supabase_functions dependency to point to the branch? What is your pubspec.yaml? deactivating edge globally and linking a CLI to a local checkout is not enough (and unnecessary), since the change is related to the edge_runtime, not cli package

henry2man commented 1 year ago

Ok, I've reverted edge to published version and I've adjusted pubspec.yaml like this. Is this what you mean?

name: supabase_edge_functions_example
description: A Supaabase Edge Functions example written in Dart.
version: 1.0.0
publish_to: none

environment:
  sdk: ">=2.18.5 <3.0.0"

dependencies:
  edge: ^0.0.5
  supabase_functions: 
    git:
      url: https://github.com/invertase/dart_edge.git
      ref: fix/request-body-access

dev_dependencies:
  lints: ^2.0.1
henry2man commented 1 year ago

Only when I have correctly understood what was being patched have I been able to test the code and verify that it already works correctly. @lesnitsky Thank you very much and apologize for any inconvenience.

The modified pubspec.yaml:

name: supabase_edge_functions_example
description: A Supaabase Edge Functions example written in Dart.
version: 1.0.0
publish_to: none

environment:
  sdk: ">=2.18.5 <3.0.0"

dependencies:
  edge: ^0.0.5
  supabase_functions: any

dev_dependencies:
  lints: ^2.0.1

dependency_overrides: 
  edge_runtime: 
    git:
      url: https://github.com/invertase/dart_edge.git
      ref: fix/request-body-access
      path: packages/edge_runtime
lesnitsky commented 1 year ago

no worries, thanks for finding this issue and providing a good repro 👍

henry2man commented 1 year ago

Confirmed, it works like a charm. Can be merged! 🚀