Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6782,6 +6782,35 @@ tasks:
mongosh_server_test_version: "latest-alpha-enterprise"
mongosh_test_force_api_strict: "1"
task_name: ${task_name}

###
# NODE.JS NIGHTLY EARLY-WARNING TASK
#
# Runs the e2e suite against the *source* mongosh (no boxednode compile)
# using a prebuilt Node.js nightly binary fetched via nvm. We rely on
# Node.js's official nightly builders for the V8 toolchain — our job is
# only to verify that mongosh's source + native addons work on the next
# upcoming Node.js release. Tagged "node-nightly-test" so it does not
# gate releases via the .e2e-test / .compile-artifact dependency chains.
###
- name: test_e2e_node_nightly
tags: ["node-nightly-test", "assigned_to_jira_team_mongosh_mongosh"]
depends_on:
- name: compile_ts
variant: linux_compile
commands:
- func: checkout
- func: install
vars:
node_js_version: ${node_js_version}
- func: test
vars:
node_js_version: ${node_js_version}
mongosh_server_test_version: ${mongosh_server_test_version}
mongosh_skip_node_version_check: "1"
mongosh_test_id: e2e_tests_node_nightly
mongosh_run_only_in_package: e2e-tests
task_name: ${task_name}
- name: compile_artifact
tags: ["compile-artifact"]
depends_on:
Expand Down Expand Up @@ -13539,6 +13568,15 @@ buildvariants:
- name: test_vscode
- name: test_connectivity
- name: test_apistrict
- name: linux_node_nightly
display_name: "Ubuntu 20.04 x64 (Node.js nightly e2e)"
run_on: ubuntu2004-small
tags: ["node-nightly-test"]
expansions:
node_js_version: "nightly"
mongosh_server_test_version: "stable-enterprise"
tasks:
- name: test_e2e_node_nightly
- name: linux_coverage
display_name: "Ubuntu 20.04 x64 (Coverage and Static Analysis Check)"
run_on: ubuntu2004-small
Expand Down
38 changes: 38 additions & 0 deletions .evergreen/evergreen.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,35 @@ tasks:
mongosh_server_test_version: "latest-alpha-enterprise"
mongosh_test_force_api_strict: "1"
task_name: ${task_name}

###
# NODE.JS NIGHTLY EARLY-WARNING TASK
#
# Runs the e2e suite against the *source* mongosh (no boxednode compile)
# using a prebuilt Node.js nightly binary fetched via nvm. We rely on
# Node.js's official nightly builders for the V8 toolchain — our job is
# only to verify that mongosh's source + native addons work on the next
# upcoming Node.js release. Tagged "node-nightly-test" so it does not
# gate releases via the .e2e-test / .compile-artifact dependency chains.
###
- name: test_e2e_node_nightly
tags: ["node-nightly-test", "assigned_to_jira_team_mongosh_mongosh"]
depends_on:
- name: compile_ts
variant: linux_compile
commands:
- func: checkout
- func: install
vars:
node_js_version: ${node_js_version}
- func: test
vars:
node_js_version: ${node_js_version}
mongosh_server_test_version: ${mongosh_server_test_version}
mongosh_skip_node_version_check: "1"
mongosh_test_id: e2e_tests_node_nightly
mongosh_run_only_in_package: e2e-tests
task_name: ${task_name}
- name: compile_artifact
tags: ["compile-artifact"]
depends_on:
Expand Down Expand Up @@ -1626,6 +1655,15 @@ buildvariants:
- name: test_vscode
- name: test_connectivity
- name: test_apistrict
- name: linux_node_nightly
display_name: "Ubuntu 20.04 x64 (Node.js nightly e2e)"
run_on: ubuntu2004-small
tags: ["node-nightly-test"]
expansions:
node_js_version: "nightly"
mongosh_server_test_version: "stable-enterprise"
tasks:
- name: test_e2e_node_nightly
- name: linux_coverage
display_name: "Ubuntu 20.04 x64 (Coverage and Static Analysis Check)"
run_on: ubuntu2004-small
Expand Down
42 changes: 41 additions & 1 deletion .evergreen/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ set -x
OS_ARCH="$(uname "-m")"

export BASEDIR="$PWD/.evergreen"

# When NODE_JS_VERSION=nightly, download the latest Node.js nightly tarball
# directly from https://nodejs.org/download/nightly/ and pin to its concrete
# version string for the remainder of this task. The first invocation in a
# task downloads; subsequent invocations read $RESOLVED_NIGHTLY_FILE so
# install + compile commands agree on the same version.
#
# scripts/import-expansions.js (loaded by every evergreen-release run via
# ts-node) re-applies the YAML expansions on top of the process env, which
# would clobber NODE_JS_VERSION back to "nightly". It honors a *_OVERRIDE
# suffix though, so we also export NODE_JS_VERSION_OVERRIDE.
RESOLVED_NIGHTLY_FILE="$BASEDIR/.resolved-nightly-node-version"
NIGHTLY_NODE_DIR="$BASEDIR/node-nightly"
if [ "$NODE_JS_VERSION" = "nightly" ]; then
if [ -s "$RESOLVED_NIGHTLY_FILE" ]; then
NODE_JS_VERSION=$(cat "$RESOLVED_NIGHTLY_FILE")
else
NODE_JS_VERSION=$(curl -sSfL https://nodejs.org/download/nightly/index.json \
| python3 -c 'import sys,json; print(json.load(sys.stdin)[0]["version"].lstrip("v"))')
echo "$NODE_JS_VERSION" > "$RESOLVED_NIGHTLY_FILE"
fi
if [ ! -x "$NIGHTLY_NODE_DIR/bin/node" ]; then
mkdir -p "$NIGHTLY_NODE_DIR"
curl -sSfL "https://nodejs.org/download/nightly/v$NODE_JS_VERSION/node-v$NODE_JS_VERSION-linux-x64.tar.xz" \
| tar -xJ --strip-components=1 -C "$NIGHTLY_NODE_DIR"
fi
export PATH="$NIGHTLY_NODE_DIR/bin:$PATH"
export NODE_JS_VERSION
export NODE_JS_VERSION_OVERRIDE="$NODE_JS_VERSION"
export USE_NIGHTLY_NODE=1
fi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nvm feels a bit like overkill for downloading and extracting from https://nodejs.org/download/nightly/ for a single architecture and target OS

(aside: the ticket itself wasn't asking for nightlies, but I don't mind using them as long as the team is okay with that overall)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Node.js latest or nightly builds as an early warning system for breakages

I guess I just went with the second half of the OR and didn't think too much about it 😅 latest node would def be easier, but I'm wondering if we're a good canary in the coal mine with how deeply we integrate with the platform that nightlies could be more interesting, could also be more noisy...


export PATH="$BASEDIR/node-v$NODE_JS_VERSION-win-x64:/opt/java/jdk17/bin:$PATH"
export MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING="$BASEDIR/../packages/testing/tests-globalconfig.conf"

Expand Down Expand Up @@ -45,9 +77,11 @@ if [ "$OS" != "Windows_NT" ]; then

echo "Using gcc version:"
(which gcc && gcc --version)
"$CC" --version | head -1

echo "Using g++ version:"
(which g++ && g++ --version)
"$CXX" --version | head -1
fi
else
export NODE_GYP_FORCE_PYTHON="C:\python\Python311\python.exe"
Expand All @@ -56,7 +90,13 @@ fi

NODE_JS_MAJOR_VERSION=$(echo "$NODE_JS_VERSION" | awk -F . '{print $1}')
if echo "$NODE_JS_MAJOR_VERSION" | grep -q '^[0-9]*$'; then
export PATH="/opt/devtools/node$NODE_JS_MAJOR_VERSION/bin:$PATH"
if [ -n "$USE_NIGHTLY_NODE" ]; then
# The Linux branch above prepended /opt/devtools/bin (which ships its own
# `node`), so re-prepend the downloaded nightly bin to make sure it wins.
export PATH="$NIGHTLY_NODE_DIR/bin:$PATH"
else
export PATH="/opt/devtools/node$NODE_JS_MAJOR_VERSION/bin:$PATH"
fi
echo "Detected Node.js version (requested v${NODE_JS_MAJOR_VERSION}.x):"
node -v
node -v | grep -q "^v$NODE_JS_MAJOR_VERSION"
Expand Down
7 changes: 5 additions & 2 deletions packages/build/src/compile/signable-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ async function preCompileHook(nodeSourceTree: string) {
'nodejs-patches'
);
// Sort all entries in the directory so that they are applied
// in order 001-(...).patch, 002-(...).patch, etc.
const patchFiles = (await fs.readdir(patchDirectory)).sort();
// in order 001-(...).patch, 002-(...).patch, etc. Only .patch files are
// applied so README/disabled drafts can sit alongside in the same directory.
const patchFiles = (await fs.readdir(patchDirectory))
.filter((entry) => entry.endsWith('.patch'))
.sort();
for (const entry of patchFiles) {
const patchFile = path.resolve(patchDirectory, entry);
console.warn(`Applying patch from ${patchFile}...`);
Expand Down
9 changes: 8 additions & 1 deletion packages/cli-repl/src/cli-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,14 @@ export class CliRepl implements MongoshIOProvider {
);
}

if (!semver.satisfies(process.version, RECOMMENDED_NODEJS)) {
// includePrerelease so that running on a Node.js nightly / RC / beta
// (e.g. v26.0.0-nightly20260428...) doesn't get a spurious "lower than
// 24.0.0" warning — semver.satisfies excludes prereleases by default.
if (
!semver.satisfies(process.version, RECOMMENDED_NODEJS, {
includePrerelease: true,
})
) {
warnings.push(
' - Using mongosh with Node.js versions lower than 24.0.0 is deprecated, and support may be removed in a future release.'
);
Expand Down
38 changes: 31 additions & 7 deletions packages/e2e-tests/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ describe('e2e', function () {

describe('--build-info', function () {
it('shows build info in JSON format', async function () {
// TODO(MONGOSH-3334): Under Node.js nightlies the glibc-version
// native addon's dlsym for `gnu_get_libc_version` returns null on
// some builders (e.g. ubuntu2004), so mongosh reports
// runtimeGlibcVersion = "N/A" while Node.js's process.report still
// sees the host's glibc. Investigate the addon's loader behavior
// under the nightly's prebuilt binary and re-enable.
if (process.version.includes('-nightly')) {
return this.skip();
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we create separate tickets for these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, created!

const shell = startTestShell(this, { args: ['--build-info'] });
await shell.waitForSuccessfulExit();

Expand Down Expand Up @@ -772,6 +781,14 @@ describe('e2e', function () {
});

it('sets device ID for telemetry', async function () {
// TODO(MONGOSH-3334): Under Node.js nightlies the native-machine-id
// addon throws on some builders (e.g. ubuntu2004), so mongosh's
// telemetry deviceId falls back to the literal string "unknown".
// Pairs with the glibc-version skip in --build-info above; both
// point at the same loader/dlsym behavior under the nightly binary.
if (process.version.includes('-nightly')) {
return this.skip();
}
const deviceId = (
await shell.executeLine(
'db._mongo._instanceState.evaluationListener.ioProvider.loggingAndTelemetry.deviceId'
Expand Down Expand Up @@ -1377,19 +1394,19 @@ describe('e2e', function () {
});
await shell.waitForSuccessfulExit();

// Check that:
// - the script runs in the expected environment
// - async promise tracking is enabled if and only if we are running in REPL mode
// The latter is particularly important because the performance benefits of
// avoiding REPL mode mostly stem from the lack of async promise tracking.
// Check that the script runs in the expected environment.
// We used to also assert executionAsyncId > 1 in REPL mode as a
// proxy for "async promise tracking is enabled" — that was an
// observable side effect of REPL loading the `domain` module.
// nodejs/node#61227 removed REPL's domain dependency, so on Node
// v26+ both modes report executionAsyncId === 0 and the proxy no
// longer distinguishes them.
const result = EJSON.parse(shell.output);
expect(result.usingPlainVMContext).to.deep.equal(
!jsContextFlags.includes('--jsContext=repl')
);
if (result.usingPlainVMContext) {
expect(result.executionAsyncId).to.equal(0);
} else {
expect(result.executionAsyncId).to.be.greaterThan(1);
}
shell.assertNoErrors();
});
Expand Down Expand Up @@ -2313,6 +2330,13 @@ describe('e2e', function () {
});

it('shows an update notification if a newer version is available', async function () {
// TODO(MONGOSH-3335): the update notification doesn't surface in
// the captured shell output on Node.js nightlies — needs a closer
// look at how the update-fetch interacts with the local httpServer
// fixture under the nightly's HTTP/fetch implementation.
if (process.version.includes('-nightly')) {
return this.skip();
}
{
const shell = await startNodbTestShellAndWaitForPrompt(
this,
Expand Down
Loading