Skip to content

[BUG] Bun module exports are returned as undefined #61

@notkadez

Description

@notkadez

Summary

When secure-exec runs under Bun as the host, Bun's node:v8.deserialize() rejects payload bytes produced by the Rust V8 runtime. Node accepts those same bytes.

This breaks Bun-host run() export decoding and any other host-side decode path that consumes Rust V8 ValueSerializer output.

Minimal repro

Node serialized bytes:

node -e "const v8=require('node:v8'); process.stdout.write(v8.serialize({message:'hello'}).toString('hex'))"

Observed:

ff0f6f22076d657373616765220568656c6c6f7b01

Bun serialized bytes:

bun --eval "import v8 from 'node:v8'; process.stdout.write(Buffer.from(v8.serialize({message:'hello'})).toString('hex'))"

Observed:

0d00000002070000806d657373616765100500008068656c6c6fffffffff

Bun deserializing the Node/Rust bytes:

bun --eval "import v8 from 'node:v8'; const hex='ff0f6f22076d657373616765220568656c6c6f7b01'; try { console.log(JSON.stringify(v8.deserialize(Buffer.from(hex,'hex')))); } catch (err) { console.error(String(err)); process.exit(1); }"

Observed:

TypeError: Unable to deserialize data.

Control:

node -e "const v8=require('node:v8'); const hex='ff0f6f22076d657373616765220568656c6c6f7b01'; console.log(JSON.stringify(v8.deserialize(Buffer.from(hex,'hex'))))"

Observed:

{"message":"hello"}

Impact

  • Bun host cannot decode Rust V8 runtime exports
  • Bun host behavior diverges from Node on the same V8 payloads

Root cause

Bun's node:v8 implementation is not compatible with real V8 wire format; instead it uses JavaScriptCore wire format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions