From 44d160cdde9ddf515661efd931e7b1ff4664450c Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 20 Jun 2024 08:52:09 -0500 Subject: [PATCH] Spelunking into #3270 incompatibility with ava test runner --- package.json | 2 +- src/Util/Require.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7dbda404f..854405397 100755 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "scripts": { "default": "npm run test", "test": "npm run test:node && npm run test:ava", - "test:ava": "cross-env ELEVENTY_SKIP_ESM_RESOLVER=1 npx ava --verbose", + "test:ava": "npx ava --verbose --timeout 20s", "test:node": "node --test test_node/tests.js", "jsdoc": "rm -rf jsdoc && npx jsdoc src/* -r -d jsdoc", "format": "prettier . --write", diff --git a/src/Util/Require.js b/src/Util/Require.js index d90c84c53..c4b569e9e 100644 --- a/src/Util/Require.js +++ b/src/Util/Require.js @@ -13,7 +13,9 @@ const { port1, port2 } = new MessageChannel(); // ESM Cache Buster is an enhancement that works in Node 18.19+ // https://nodejs.org/docs/latest/api/module.html#moduleregisterspecifier-parenturl-options // Fixes https://github.com/11ty/eleventy/issues/3270 -// Temporary: ELEVENTY_SKIP_ESM_RESOLVER to opt-out of Node 22 Ubuntu tests + +// Temporary: ELEVENTY_SKIP_ESM_RESOLVER for test suite only to workaround incompatibility +// with Ava’s worker threads (timed out on Node 22 Ubuntu) if ("register" in module && !process.env.ELEVENTY_SKIP_ESM_RESOLVER) { module.register("./EsmResolver.js", import.meta.url, { data: { @@ -57,7 +59,7 @@ eventBus.on("eleventy.importCacheReset", (fileQueue) => { lastModifiedPaths.set(absolutePath, newDate); // post to EsmResolver worker thread - if (port1) { + if (!process.env.ELEVENTY_SKIP_ESM_RESOLVER && port1) { port1.postMessage({ path: absolutePath, newDate }); }