Skip to content

Cannot allocate Buffer into Chromium v8. #1346

Description

@hallahan

I have a function like so:

  pub async fn tile(&self, z: u8, x: u32, y: u32) -> Result<Buffer> {
    tokio::task::spawn(async move { 
      let t = Tile::from_zxy(z, x, y);
      let buf = tile_info(t).into();
      Ok(buf)
    }).await.unwrap()
  }

However, whenever I call it from an Electron app, with sandboxing turned off, I still get the following error:

[31872:1015/170858.344491:ERROR:node_bindings.cc(146)] Fatal error in V8: v8_ArrayBuffer_NewBackingStore When the V8 Sandbox is enabled, ArrayBuffer backing stores must be allocated inside the sandbox address space. Please use an appropriate ArrayBuffer::Allocator to allocate these buffers.

I want to essentially have a Vec<u8 / Uint8Array of data created in a tokio task, and I want to access that data in NodeJS. Am I doing this wrong, or is there a bug here?

Is there a way to tell v8 to allocate a buffer, and do it from within a tokio task?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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