Skip to content

Incorrect built-in Math constants in edge-runtime v1.74.3; Math.LN10 also wrong in v1.74.2 (linux/amd64) #723

Description

@raf-master

Bug report

Several native JavaScript Math.* constants return incorrect values inside supabase/edge-runtime:v1.74.3.

The issue reproduces with a single dependency-free TypeScript file. The equivalent probe returns the expected values in the official Deno 2.1.4 container.

Math.LN10 was also independently reproduced as incorrect in edge-runtime v1.74.2, including after deleting and cleanly pulling the same image digest.

Environment

  • Docker Desktop Server: 28.3.2
  • Docker operating system: Linux
  • Docker host architecture: x86_64
  • Kernel: 6.6.87.2-microsoft-standard-WSL2
  • Supabase CLI: 2.109.1
  • Control image: denoland/deno:2.1.4

Deno control:

  • Deno 2.1.4
  • V8 13.0.245.12-rusty
  • Target x86_64-unknown-linux-gnu

Edge Runtime v1.74.3:

  • Image: public.ecr.aws/supabase/edge-runtime:v1.74.3
  • Image ID: sha256:c52405002a890ca9fcf77978671c57f3a988e03174afb277f84ac65bc917013c
  • RepoDigest: public.ecr.aws/supabase/edge-runtime@sha256:c52405002a890ca9fcf77978671c57f3a988e03174afb277f84ac65bc917013c
  • Architecture: amd64
  • OS: linux
  • Created: 2026-07-31T04:09:03.225642475Z
  • Runtime reports:
    • edge-runtime 0.1.0
    • deno 2.1.4 (release, x86_64-unknown-linux-gnu)

Additional v1.74.2 evidence:

  • Image: public.ecr.aws/supabase/edge-runtime:v1.74.2
  • Digest: sha256:a82676277615aee03c4f288cbbbf68dedb5ba8693073e567ab8dbfdd11ba5d45
  • Architecture: amd64/linux

No application or Supabase environment variables were passed to the isolated v1.74.3 reproducer.

Minimal reproduction

Create <temp-dir>/index.ts:

function bits(value: number): string {
  const buffer = new ArrayBuffer(8);
  new DataView(buffer).setFloat64(0, value, false);

  return Array.from(new Uint8Array(buffer))
    .map((b) => b.toString(16).padStart(2, "0"))
    .join("");
}

const constants = {
  E: Math.E,
  LN2: Math.LN2,
  LN10: Math.LN10,
  LOG2E: Math.LOG2E,
  LOG10E: Math.LOG10E,
  PI: Math.PI,
  SQRT1_2: Math.SQRT1_2,
  SQRT2: Math.SQRT2,
};

Deno.serve(() =>
  Response.json(
    Object.fromEntries(
      Object.entries(constants).map(([name, value]) => [
        name,
        {
          value: value.toPrecision(17),
          bits: bits(value),
        },
      ]),
    ),
  ),
);

Replace <temp-dir> below with its absolute host path.

docker pull public.ecr.aws/supabase/edge-runtime:v1.74.3
docker run -d --rm --name edge-math-runtime-1743-repro --mount type=bind,source=<temp-dir>,target=/probe,readonly -p 127.0.0.1::9000 public.ecr.aws/supabase/edge-runtime:v1.74.3 start --main-service=/probe --port=9000 --policy=per_worker
docker port edge-math-runtime-1743-repro 9000/tcp
curl http://127.0.0.1:<edge-host-port>/
docker stop edge-math-runtime-1743-repro

No dependency installation is necessary.

Expected behavior

The built-in constants should match standard JavaScript/Deno values and IEEE-754 representations:

Constant Expected value Expected bits
Math.E 2.7182818284590451 4005bf0a8b145769
Math.LN2 0.69314718055994529 3fe62e42fefa39ef
Math.LN10 2.3025850929940459 40026bb1bbb55516
Math.LOG2E 1.4426950408889634 3ff71547652b82fe
Math.LOG10E 0.43429448190325182 3fdbcb7b1526e50e
Math.PI 3.1415926535897931 400921fb54442d18
Math.SQRT1_2 0.70710678118654757 3fe6a09e667f3bcd
Math.SQRT2 1.4142135623730951 3ff6a09e667f3bcd

Actual behavior

Edge Runtime v1.74.3 returns:

Constant Actual value Actual bits
Math.E 2.0000000000000000 4000000000000000
Math.LN2 0.0000000000000000 0000000000000000
Math.LN10 2.0000000000000000 4000000000000000
Math.LOG2E 1.0000000000000000 3ff0000000000000
Math.LOG10E 0.0000000000000000 0000000000000000
Math.PI 3.1415926535897931 400921fb54442d18
Math.SQRT1_2 0.70710678118654757 3fe6a09e667f3bcd
Math.SQRT2 1.4142135623730951 3ff6a09e667f3bcd

Control

Run the same index.ts with Deno 2.1.4:

docker run -d --rm --name edge-math-deno-control --mount type=bind,source=<temp-dir>,target=/probe,readonly -p 127.0.0.1::8000 denoland/deno:2.1.4 deno run --allow-net /probe/index.ts
docker port edge-math-deno-control 8000/tcp
curl http://127.0.0.1:<deno-host-port>/
docker stop edge-math-deno-control

The Deno control returns every expected value and bit pattern.

Additional evidence

With Edge Runtime v1.74.2:

  • Math.LN10 returned 2.0000000000000000
  • Actual bits: 4000000000000000
  • Expected bits: 40026bb1bbb55516

The v1.74.2 image was deleted and cleanly pulled again. The pulled image had the same expected digest and reproduced the same incorrect result.

This refutes a simple local image/cache corruption explanation.

Impact

Code performing mathematical operations may silently receive incorrect built-in constants.

Libraries that validate or use these constants can fail during module initialization or produce incorrect numerical results.

As one observed downstream example, decimal.js-light validates Math.LN10 during initialization and throws when the value does not match. The library is not required for this reproduction.

Notes

  • The reproducer contains only native JavaScript/TypeScript.
  • No external dependency is imported.
  • No database, secrets, application environment, or application code is involved.
  • The exact internal cause has not been established.
  • V8 snapshot corruption, serialization, Docker Desktop/WSL2 behavior, Windows-host specificity, or a deno_core/V8 issue remain hypotheses only.
  • Reproduction on a native Linux host has not yet been tested.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions