-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NODE_V8_COVERAGE broken on OSX (perhaps other platforms) #25287
Comments
Initializing coverage, relies on diff --git a/lib/internal/process/coverage.js b/lib/internal/process/coverage.js
index 5c5d0c2b61..e3cf74f395 100644
--- a/lib/internal/process/coverage.js
+++ b/lib/internal/process/coverage.js
@@ -76,9 +76,10 @@ function setup() {
}));
try {
+ const { cwd } = internalBinding('process_methods');
const { resolve } = require('path');
coverageDirectory = process.env.NODE_V8_COVERAGE =
- resolve(process.env.NODE_V8_COVERAGE);
+ resolve(cwd(), process.env.NODE_V8_COVERAGE);
} catch (err) {
console.error(err);
} It might just be simpler to move the coverage setup until after the EDIT: It's also worth noting that the existing code without this patch does throw an exception, but |
Thanks for investigating! Joyee probably has an easier time digging in as she’s on OSX as well (I think).
This happens very early during bootstrap, so I assume it’s not that. |
Here is an alternative approach that moves the coverage setup to a later point in the bootstrapping process. It sacrifices a bit of core internals coverage, but the process is in a much more usable state: diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js
index 93fb186574..d8d0827e2d 100644
--- a/lib/internal/bootstrap/loaders.js
+++ b/lib/internal/bootstrap/loaders.js
@@ -353,12 +353,6 @@ NativeModule.prototype.cache = function() {
NativeModule._cache[this.id] = this;
};
-// Coverage must be turned on early, so that we can collect
-// it for Node.js' own internal libraries.
-if (process.env.NODE_V8_COVERAGE) {
- NativeModule.require('internal/process/coverage').setup();
-}
-
function internalBindingWhitelistHas(name) {
if (!internalBindingWhitelistSet) {
const { SafeSet } = NativeModule.require('internal/safe_globals');
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 3c14d4851a..87fd2076f3 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -141,7 +141,11 @@ function startup() {
NativeModule.require('internal/process/write-coverage').setup();
if (process.env.NODE_V8_COVERAGE) {
- NativeModule.require('internal/process/coverage').setupExitHooks();
+ const { setup, setupExitHooks } =
+ NativeModule.require('internal/process/coverage');
+
+ setup();
+ setupExitHooks();
}
if (process.config.variables.v8_enable_inspector) { |
@cjihrig my preference would be to keep the bootstrapping is early as possible, assuming we can actually raise a build failure if we have a regression like this. If we move initialization too late, it makes it difficult to use |
i'm in favor of the first patch. @bcoe i think you can use process._rawDebug instead of console.error |
For now, using methods that are available earlier during bootstrap sounds good to me (thanks @cjihrig !) though I wonder whether we should postpone the setup to some point later, or move |
Another way to fix the particular issue at hand is to postpone the |
@joyeecheung you are correct that the Unrelated, shouldn't this have broken tests? we should make sure that our regression tests actually work before we land a fix. |
I updated the coverage test in #25289, so this should be caught moving forward. |
console is not ready to use at this point in the bootstrapping process, so switch to process._rawDebug() instead. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
During coverage setup, path.resolve() is called. path.resolve() can potentially call process.cwd(), which hasn't been bootstrapped yet. This commit passes the current working directory directly so that path.resolve() doesn't attempt to compute it. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Update the coverage test to verify that nothing is printed to stderr (which happens when coverage errors happen). Also add a test case to verify that non-absolute coverage paths work. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
console is not ready to use at this point in the bootstrapping process, so switch to process._rawDebug() instead. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
During coverage setup, path.resolve() is called. path.resolve() can potentially call process.cwd(), which hasn't been bootstrapped yet. This commit passes the current working directory directly so that path.resolve() doesn't attempt to compute it. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Update the coverage test to verify that nothing is printed to stderr (which happens when coverage errors happen). Also add a test case to verify that non-absolute coverage paths work. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
console is not ready to use at this point in the bootstrapping process, so switch to process._rawDebug() instead. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
During coverage setup, path.resolve() is called. path.resolve() can potentially call process.cwd(), which hasn't been bootstrapped yet. This commit passes the current working directory directly so that path.resolve() doesn't attempt to compute it. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Update the coverage test to verify that nothing is printed to stderr (which happens when coverage errors happen). Also add a test case to verify that non-absolute coverage paths work. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
console is not ready to use at this point in the bootstrapping process, so switch to process._rawDebug() instead. PR-URL: #25289 Fixes: #25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: #25496
During coverage setup, path.resolve() is called. path.resolve() can potentially call process.cwd(), which hasn't been bootstrapped yet. This commit passes the current working directory directly so that path.resolve() doesn't attempt to compute it. PR-URL: #25289 Fixes: #25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: #25496
Update the coverage test to verify that nothing is printed to stderr (which happens when coverage errors happen). Also add a test case to verify that non-absolute coverage paths work. PR-URL: #25289 Fixes: #25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: #25496
console is not ready to use at this point in the bootstrapping process, so switch to process._rawDebug() instead. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: nodejs#25496
During coverage setup, path.resolve() is called. path.resolve() can potentially call process.cwd(), which hasn't been bootstrapped yet. This commit passes the current working directory directly so that path.resolve() doesn't attempt to compute it. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: nodejs#25496
Update the coverage test to verify that nothing is printed to stderr (which happens when coverage errors happen). Also add a test case to verify that non-absolute coverage paths work. PR-URL: nodejs#25289 Fixes: nodejs#25287 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: nodejs#25496
#25127 seems to break coverage on OSX:
My guess is that coverage might be initialized either before the inspector is running, or before the
process.env
object has been populated.Not sure why this wouldn't have been caught in the linux test suite.
I believe this is the root cause of nodejs/node-v8#97
CC: @nodejs/build
The text was updated successfully, but these errors were encountered: