deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

[Bug]: The deployment failed: UNCAUGHT_EXCEPTION - Failed to load native binding for @swc/core

Open Thesephi opened this issue 9 months ago • 2 comments
trafficstars

Problem description

I have a custom Deno project, in which I use @swc/core. It works on local & remote (Ubuntu 24.04.1 where I deploy manually myself). But when deploying with Deno Deploy, the step Upload to Deno Deploy currently fails like so: https://github.com/fullsoak/examples/actions/runs/13147196665/job/36687795407#step:6:206

Error: The deployment failed: UNCAUGHT_EXCEPTION

Error: Failed to load native binding
    at Object.<anonymous> (file:///node_modules/.deno/@[email protected]/node_modules/@swc/core/binding.js:329:11)
    at Object.<anonymous> (file:///node_modules/.deno/@[email protected]/node_modules/@swc/core/binding.js:353:4)
    at Module._compile (node:module:745:34)
    at loadMaybeCjs (node:module:770:10)
    at Object.Module._extensions..js (node:module:755:12)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:812:16)
    at Object.<anonymous> (file:///node_modules/.deno/@[email protected]/node_modules/@swc/core/index.js:49:17)

I'm aware this might also be an issue with @swc/core (not necessarily an issue with Deno Deploy alone), just that we're in an early stage everywhere and I feel a report for awareness wouldn't hurt. If I could help with further debugging ie pair-programming for example), I'd also be happy to!

Any suggestion is appreciated, thank you!

Steps to reproduce

  1. configure this GitHub repo for Deno Deploy: https://github.com/fullsoak/examples.git (feel free to fork if needed 🙂)
  2. use this script for the Install Step: deno install --allow-scripts=npm:@swc/core
  3. use this file for the Entrypoint: src/main.ts
  4. proceeding with Deno Deploy, notice that the "Install step" does succeed, but then it fails at the Upload to Deno Deploy step (example)

Expected behavior

The Deno Deploy process succeeds.

Environment

  • Deno version: 2.1.9
  • GitHub Action Runner version: 2.322.0 (runner image = ubuntu-24.04; OS = Ubuntu 24.04.1)

Possible solution

Atm I have no concrete knowledge, but the log Finishing deployment... did show up: https://github.com/fullsoak/examples/actions/runs/13147196665/job/36687795407#step:6:205

Meaning it crashes somewhere after this line in the deployctl logic: https://github.com/denoland/deployctl/blob/main/src/subcommands/deploy.ts#L350 - tho I'm not familiar with this logic, so please take this point only with a grain of salt.

Additional context

No response

Thesephi avatar Feb 05 '25 01:02 Thesephi

Additional context: I tried switching from @swc/core to esbuild, and the Deno Deploy process was finally successful. However as we do dynamic import (ie await import("esbuild"), it means esbuild can still fail to load during run-time.

On local & "normal" hosting environments, all is fine. But on Deno Deploy, currently this is what happens:

Error: The package "@esbuild/linux-x64" could not be found, and is needed by esbuild.
Image

This is also reproducible when we do deno compile on local & execute the resulted binary.

Afais, it could be concluded that native bindings are not supported either with deno compile or Deno Deploy.

I don't know if this is a known issue for Deno Deploy, but it sure is for deno compile: https://github.com/denoland/deno/issues/27082 - so for now I'll leave this ticket open for related discussions. Also the theme is large, so there may be multiple smaller issues combined.

Hope this is helpful for anyone else stumbling upon the same bump 💪

Thesephi avatar Feb 15 '25 20:02 Thesephi

I also get:

Project linked to GitHub
Downloaded file:///src/main.ts (1/2)
Downloaded file:///src/mod.ts (2/2)
Packaging complete
The deployment failed: UNCAUGHT_EXCEPTION Error: Cannot find module 'whatlang-node-linux-x64-gnu' Require stack: - /node_modules/.deno/[email protected]/node_modules/whatlang-node/index.js - /node_modules/.deno/[email protected]/node_modules/whatlang-node/index.js at Module._resolveFilename (node:module:619:15) at Module._load (node:module:497:27) at Module.require (node:module:681:19) at require (node:module:816:16) at Object.<anonymous> (file:///node_modules/.deno/[email protected]/node_modules/whatlang-node/index.js:172:31) at Object.<anonymous> (file:///node_modules/.deno/[email protected]/node_modules/whatlang-node/index.js:236:4) at Module._compile (node:module:745:34) at loadMaybeCjs (node:module:770:10) at Object.Module._extensions..js (node:module:755:12) at Module.load (node:module:662:32)

It runs well on local.

Reproduction: https://github.com/devno-js/deeplx

JounQin avatar Apr 13 '25 16:04 JounQin

Hey @Thesephi I'm running into a similar issue on my end. Have you found any way to fix it?

GorreriFranco avatar Aug 08 '25 13:08 GorreriFranco