Skip to content

refact: wasm compatibility#18

Open
schronck wants to merge 3 commits intomainfrom
refact/wasm
Open

refact: wasm compatibility#18
schronck wants to merge 3 commits intomainfrom
refact/wasm

Conversation

@schronck
Copy link

@schronck schronck commented Feb 9, 2026

No description provided.

@schronck schronck self-assigned this Feb 9, 2026
@schronck schronck requested a review from sosaucily February 9, 2026 09:42
src/lib.rs Outdated

// Modules that require file I/O - only available on native targets
#[cfg(not(target_arch = "wasm32"))]
pub mod batch;
Copy link
Contributor

Choose a reason for hiding this comment

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

so batching isn't available with wasm? why is that?

i guess this PR will require updates to the readme when it's finalized

Copy link
Author

Choose a reason for hiding this comment

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

Currently, the problem with the batch module is that we are using the csv::Reader::from_path, but I think we can solve this by hiding only the file reading stuff behind the flag and for WASM add a parse function which will get the content of the csv from somewhere...

Copy link
Author

Choose a reason for hiding this comment

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

Pushed a fix for this

@sosaucily
Copy link
Contributor

generally i would like to see less wasm-specific logic if possible. even if it means doing things in a slightly more complicated way.

@schronck
Copy link
Author

We should eliminate all environment variable reads from the codebase because it’s generally a poor pattern. Environment variables are process-level configuration and should be read once at program startup (or at a clearly defined boundary) and then passed down explicitly as arguments (or via a config object / dependency injection). This makes behavior deterministic, improves testability, and avoids hidden global dependencies.

On UNIX-like systems (Linux, Darwin/macOS), an application receives its environment at process creation time: the parent passes an environment array into execve(), and a fork() creates a copy for the child. After the process has started, other processes cannot modify its environment; only the process itself (or code running inside it) can change it via setenv()/unsetenv() etc. So repeatedly calling getenv() during runtime rarely provides any meaningful “freshness,” and in multi-threaded code it can introduce subtle races if any thread mutates the environment.

(which is another reason to treat environment variables as immutable startup configuration and to avoid reading them from within library code...)

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.

2 participants