Skip to content

Fix wasi fds leak#98

Merged
bjorn3 merged 1 commit intobjorn3:mainfrom
haskell-wasm:fix-fds-leak
Oct 22, 2025
Merged

Fix wasi fds leak#98
bjorn3 merged 1 commit intobjorn3:mainfrom
haskell-wasm:fix-fds-leak

Conversation

@TerrorJack
Copy link
Contributor

Closes #97, implement free-list allocation for wasi fds, and auto-close non-preopen fds after starting a wasip1 command module.

src/wasi.ts Outdated
this.fds.splice(fd, this.fds.length - fd);
break;
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single WASI instance shouldn't be reused across multiple .start() calls, so this can close all fds. This should still call fd_close on individual fds though, they may want a custom cleanup.

I'm a bit concerned about breaking existing users that may be reusing WASI across multiple .start() calls though. Maybe moving this commit to a separate PR that could be merged for a future v0.3 release would be a solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. I've removed the commit and will open a follow-up one after this one lands.

@bjorn3 bjorn3 merged commit 8dee247 into bjorn3:main Oct 22, 2025
1 check passed
@TerrorJack TerrorJack deleted the fix-fds-leak branch October 22, 2025 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement free list for wasi fds

2 participants