Skip to content
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

Edge function segfaults when served by CLI - but not in prod or with deno run #207

Closed
hwallis93 opened this issue Nov 8, 2023 · 3 comments · Fixed by #227
Closed

Edge function segfaults when served by CLI - but not in prod or with deno run #207

hwallis93 opened this issue Nov 8, 2023 · 3 comments · Fixed by #227
Labels

Comments

@hwallis93
Copy link

Describe the bug
I have an edge function that uses the node-onesignal package to send an email.

If I run it with supabase functions serve it starts fine, but when it's triggered (by curl for my testing) serve reports a segfault and exits.

The function works as expected when:

  • run with deno run --allow-net <path> and triggered by navigating to localhost:8000
  • deployed, then triggered by a webhook

It segfaults on await onesignal.createNotification(notification). If I comment that line out everything else works as expected.

To Reproduce

  1. Create a new function
supabase functions new my-function
  1. Replace my-function/index.ts with
import * as OneSignal from "https://esm.sh/@onesignal/node-onesignal@2.0.1-beta2";

console.log("Hello from Functions!");

const _OnesignalAppId_ = "my_onesignal_app_id";
const _OnesignalUserAuthKey_ = "my_onesignal_userauth_key";
const _OnesignalRestApiKey_ = "my_onesignal_rest_api_key";

const onesignal = new OneSignal.DefaultApi(OneSignal.createConfiguration({
  userKey: _OnesignalUserAuthKey_,
  appKey: _OnesignalRestApiKey_,
}));

Deno.serve(async () => {
  const notification = new OneSignal.Notification();

  notification.app_id = _OnesignalAppId_;
  notification.include_email_tokens = ["myemail@test.com"];
  notification.email_body = "Body";
  notification.email_subject = "Subject";

  console.log("Sending");
  await onesignal.createNotification(notification);  // <-- This triggers the segfault
  console.log("Sent");

  return new Response();
});
  1. Serve with
supabase functions serve --debug
  1. Trigger with
curl --request POST 'http://localhost:54321/functions/v1/my-function' \
  --header 'Authorization: Bearer my_anon_key' \
  --header 'Content-Type: application/json'
  1. See the following printed to console:
[Info] Sending

Segmentation fault (core dumped)
2023/11/08 19:01:16 Sent Header: Host [api.moby.localhost]
2023/11/08 19:01:16 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2023/11/08 19:01:16 Send Done
2023/11/08 19:01:16 Recv First Byte
error running container: exit 139

Expected behavior
I would expect:

  • The function to execute successfully without hitting a segfault
  • The behaviour locally to match the behaviour in production (it works in production, the email is sent)

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.3 LTS
  • Version of CLI: 1.111.2
  • Local Deno version: 1.38.0
@sweatybridge sweatybridge transferred this issue from supabase/cli Nov 9, 2023
@sweatybridge
Copy link

Transferring because it sounds like an issue with edge runtime container.

@samuelbohl
Copy link

samuelbohl commented Dec 4, 2023

Similar problem here. For me, it worked fine with the CLI version 1.106.1 but when I tried to upgrade it always lead to me getting the segfault. I am not using a third party package, though. Just making fetch calls to some APIs. Possibly related to #199 , #200 and #204 ?

Copy link

github-actions bot commented Dec 6, 2023

🎉 This issue has been resolved in version 1.29.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants