Hi guys,
I stumbled upon a strange issue in zig/wasm and I need big brain support.
When I send a string from javascript to zig, the new std.Io.Reader.fixed is not able to find anything using takeDelimiter.
Previously, instead of transferring the string via javascript to zig/wasm I had the string embedded and std.Io.Reader.fixed takeDelimiter worked fine, so I knew should work.
So I thought that it’s the transferred data, but after validating the string - as far as I can tell it’s fine - I tried the old std.io.reader and I was able to break up the input into lines. I didn’t want to rewrite it with the old interface though.
On a whim, I tried using std.heap.wasm_allocator.dupe to copy the string before passing it to the new reader interface and takeDelimiter worked again, so my javascript->wasm works now, but I have no idea why I need to copy the data for the new reader.
Has anybody an idea why that might be the case?
Do I do something wrong?
source: aoc2025/src/wasm.zig at master · 8/aoc2025 · GitHub
the hosted wasm: https://8.github.io/aoc2025/
Thank you!
Take care,
Martin