Skip to content

v2.106.0: dynamic import('@opentelemetry/api') breaks React Native / Hermes builds #2380

@sbs44

Description

@sbs44

Describe the bug

@supabase/supabase-js@2.106.0 (specifically 2fe1801) introduced an optional OpenTelemetry trace-context propagation feature (packages/shared/tracing/src/extract.ts) that uses a dynamic import('@opentelemetry/api') expression.

The Hermes bytecode compiler (used by all React Native release builds on iOS and Android) does not support dynamic import() and rejects the bundle with error: Invalid expression encountered. The Metro bundle compiles fine, but the subsequent hermesc step fails, breaking the entire release build. 2.105.4 was unaffected.

This means every React Native app that upgrades to @supabase/supabase-js@2.106.0 cannot ship a release build until this is fixed or patched.

Library affected

supabase-js

Reproduction

No response

Steps to reproduce

Tried to make this as "copy and paste" as possible...

  1. Create Expo App: npx create-expo-app@latest --template default@sdk-55
  2. Enter "supabase-js-test-expo" for app name
  3. cd supabase-js-test-expo
  4. npm install @supabase/supabase-js@2.106.0
  5. touch repro.js
  6. Populate repro.js with:
import { createClient } from "@supabase/supabase-js";

createClient("https://example.supabase.co", "anon-key");
  1. npx expo export:embed --entry-file repro.js --platform ios --dev false --reset-cache --bundle-output main.jsbundle --assets-dest assets-repro --minify false --sourcemap-output main.jsbundle.map
  2. ./node_modules/hermes-compiler/hermesc/osx-bin/hermesc -emit-binary -O -out main.hbc main.jsbundle --> fails with error:
main.jsbundle:3552:57: error: Invalid expression encountered
    if (otelModulePromise === null) otelModulePromise = import(/* webpackIgnore: true */
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Emitted 1 errors. exiting.

The dozens of warning: the variable "X" was not declared lines above the error are normal DOM/Node globals for Hermes-targeted bundles and can be ignored — only the error: line is the bug. On Linux, swap osx-bin for linux64-bin.

  1. Confirm the previous version is unaffected: npm install @supabase/supabase-js@2.105.4
  2. Re-run step 7
  3. Re-run step 8 --> passes

System Info

System:
    OS: macOS 26.4.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 72.14 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.15.0 - /opt/homebrew/opt/node@24/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.12.1 - /opt/homebrew/opt/node@24/bin/npm
    pnpm: 11.1.2 - /opt/homebrew/bin/pnpm
    bun: 1.3.14 - /opt/homebrew/bin/bun
    Deno: 2.1.4 - /opt/homebrew/bin/deno
  Browsers:
    Chrome: 148.0.7778.96
    Edge: 147.0.3912.72
    Firefox: 150.0.3
    Safari: 26.4
  npmPackages:
    @supabase/supabase-js: ^2.106.0 => 2.106.0

Used Package Manager

npm

Logs

Full hermesc output on @supabase/supabase-js@2.106.0 (warnings + error)
main.jsbundle:2248:34: warning: the variable "AbortController" was not declared in anonymous function " 69#"
        if ("function" == typeof AbortController) return new AbortController();
                                 ^~~~~~~~~~~~~~~
main.jsbundle:2400:165: warning: the variable "Promise" was not declared in anonymous arrow function " 93#"
...de.push(() => "readable" === r._state ? Br(r, D) : c(undefined)), q(() => Promise.all(de.map(r => r())), true, D);
                                                                             ^~~~~~~
main.jsbundle:898:32: warning: the variable "queueMicrotask" was not declared in arrow function "y"
      if ("function" == typeof queueMicrotask) y = queueMicrotask;else {
                               ^~~~~~~~~~~~~~
main.jsbundle:1146:100: warning: the variable "structuredClone" was not declared in arrow function "ie"
    var ie = r => (ie = "function" == typeof r.transfer ? r => r.transfer() : "function" == typeof structuredClone ? r => structuredClone(r, {
                                                                                                   ^~~~~~~~~~~~~~~
main.jsbundle:2366:84: warning: the variable "self" was not declared in anonymous function " 28#"
    var wo = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof global ? global : undefined,
                                                                                   ^~~~
main.jsbundle:3552:57: error: Invalid expression encountered
    if (otelModulePromise === null) otelModulePromise = import(/* webpackIgnore: true */
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.jsbundle:3671:30: warning: the variable "URL" was not declared in function "shouldPropagateToTarget"
    if (targetUrl instanceof URL) url = targetUrl;else try {
                             ^~~
main.jsbundle:3495:14: warning: the variable "Deno" was not declared in anonymous function " 235#"
  if (typeof Deno !== "undefined") JS_ENV = "deno";else if (typeof document !== "undefined") JS_ENV = "web";else if (typeof navigator !== "undefined" && navig...
             ^~~~
... (28 more "variable X was not declared" warnings — normal DOM/Node globals for Hermes-targeted bundles)
Emitted 1 errors. exiting.
Origin of the offending expression in main.jsbundle (shows it came from supabase-js's tracing module)
//#endregion
//#region ../../shared/tracing/dist/module/extract.js
var otelModulePromise = null;
var OTEL_PKG = "@opentelemetry/api";
function loadOtel() {
  if (otelModulePromise === null) otelModulePromise = import(/* webpackIgnore: true */
  /* @vite-ignore */
  OTEL_PKG).catch(() => null);
  return otelModulePromise;
}

Captured with: grep -n -B6 -A8 'otelModulePromise = import' main.jsbundle

The //#region ../../shared/tracing/dist/module/extract.js comment is emitted by Metro at module boundaries and pinpoints @supabase/supabase-js's tracing module as the source.

Validations

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsupabase-jsRelated to the supabase-js library.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions