Skip to content

Worker memory operations fail when memory.boxSize is configured as a string #2

Description

@GaspardKirira

The supervisor memory configuration supports boxSize as either a number or a human-readable string such as "1KB".
createMemoryPool() already resolves string values correctly through parseBoxSize(), but worker-side memory operations currently use:

Number(config.memory.boxSize)

This works for numeric values like 1024, but fails for string values like "1KB" because Number("1KB") returns NaN.
This can break worker-side ctx.write() and ctx.read() operations when the supervisor is configured with a string boxSize.
Example configuration:

createSupervisor({
  maxActors: 5,
  memory: {
    poolSize: 2,
    boxSize: "1KB",
  },
  timeouts: {
    defaultLeaseMs: 2000,
  },
});

Expected behavior:
Worker memory operations should support the same boxSize formats as createMemoryPool().

Suggested fix:
Use parseBoxSize(config.memory.boxSize) inside worker memory read/write operations instead of Number(config.memory.boxSize).
A regression test should verify that an actor can write and read shared-memory data when boxSize is configured as "1KB".

Metadata

Metadata

Assignees

No one assigned

    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