Skip to content

Conversation

@randomboi404
Copy link
Contributor

This Pull Request fixes/closes #4492.

It changes the following:

  1. Ability to access ENV variables passed into boa:

Example code

const api_key = process.env.API_KEY
API_KEY=xxxxx boa -m app.js
  1. Allows future addition of other process object methods of node js.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,598 52,598 0
Passed 49,420 49,421 +1
Ignored 2,134 2,134 0
Failed 1,044 1,043 -1
Panics 0 0 0
Conformance 93.96% 93.96% +0.00%
Fixed tests (1):
test/staging/Temporal/v8/instant-to-json.js (previously Failed)

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.49%. Comparing base (6ddc2b4) to head (77c459c).
⚠️ Report is 641 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4597      +/-   ##
==========================================
+ Coverage   47.24%   56.49%   +9.25%     
==========================================
  Files         476      547      +71     
  Lines       46892    60060   +13168     
==========================================
+ Hits        22154    33933   +11779     
- Misses      24738    26127    +1389     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@randomboi404 randomboi404 requested a review from hansl February 2, 2026 17:57
Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

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

2 non-blocking nits for now. If you want to merge without addressing that's fine we can do it in a follow up PR.

@randomboi404
Copy link
Contributor Author

That makes sense.

Regarding the new TestAction::harness() since console tests haven't been migrated yet, I think it's better to let process be consistent with it and do a follow up once test harness is adopted more broadly.

Regarding it being enabled by default, I think we should let it be enabled for now and if in case we strictly don't want it enabled as it's a node api, we'll do a follow up to make it not being enabled by default.

@nekevss
Copy link
Member

nekevss commented Feb 3, 2026

I'd second having the Process extension not on by default.

I think this is a super cool extension to have as an option, but since process is not based on a web standard, we should have it be an opt in extension and not opt out.

@randomboi404
Copy link
Contributor Author

Done! I've made it optional.

Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

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

Thanks! 😄

The feature flag approach looks good to me!

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! I have a couple of questions about the implementation

Comment on lines 66 to 69
unsafe {
std::env::set_var("TEST_VAR", "test_value");
std::env::set_var("ANOTHER_VAR", "another_value");
}
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this cause UB if Cargo decides to run this test and the test below it concurrently?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, shoot. That's true.

It may be worth using something like temp_env as a dev-dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, my bad for overlooking it.
Also as per @nekevss's suggestion, I'll use temp_env as a dev dependency and fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, I don't think this fixes the issue, according to this issue in the temp_env repo. I see two possible solutions:

  • Require running tests with nextest, but it feels "weird" to depend on another test runner to not cause UB.
  • Somehow run the test in a subprocess that sets up the environment variables before running it. This is the safest way of testing this but might be much more complex to set up.

Are you open for taking a shot at the second option? If not, then I would propose ignoring the tests for now and opening an issue for fixing this later.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jedel1043 I think there is a couple other solutions:

  1. have a global mutex lock. Rust describes that set_var is only UB when multiple threads try to write at the same time. If threads are synchronized, there's no UB.
  2. merge the two tests into the same test to avoid this case. I don't recommend this one because we might add more tests in runtime with set_var later on and would likely not think about updating this test suite.

This saves having to create a subprocess which is heavy.

Ref https://doc.rust-lang.org/stable/std/env/fn.set_var.html#safety

Copy link
Member

Choose a reason for hiding this comment

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

Hmm a lot of options to discuss then.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, let's just merge after ignoring the new tests, and we can discuss the shape of our solution later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that the subprocess option would be safest but it'll be quite complex to implement for what we're trying to test here.

I think we can go for the mutex route later but I'm okay with ignoring the new tests for now and create a new issue for it where we can discuss it.

Thanks for the review!

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.

Feature: process.env

4 participants