Skip to content
Merged
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
21 changes: 9 additions & 12 deletions builder/cpu-worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ let _payloadSAB = null; // SharedArrayBuffer with packed per-task payloads
let _sharedSAB = null; // SharedArrayBuffer with packed shared payload
let _shared = null; // _sharedSAB decoded, once per lane

// What dispatch broadcast. A task that reads it runs after dispatch, so the
// SAB is here by then; renderEnvInit, which can be claimed earlier, waits
// for it first.
function sharedData() {
if (!_sharedSAB) throw new Error("the shared payload was read before dispatch broadcast it");
// What dispatch broadcast. A task that reads it runs after dispatch, but the
// message is not here by then: this lane may still be inside the pull loop
// that claimed the task, so yield until it lands, as taskData does. A
// searchIndex claimed that way threw here.
async function sharedData() {
while (!_sharedSAB) await new Promise((resolve) => setImmediate(resolve));
_shared ??= unpackShared(_sharedSAB);
return _shared;
}
Expand All @@ -74,10 +75,6 @@ const handlers = {
},

async renderEnvInit() {
while (!_sharedSAB) {
await new Promise((resolve) => setImmediate(resolve));
}

const {
siteData,
initData,
Expand All @@ -95,7 +92,7 @@ const handlers = {
pictureSizes,
counts,
downloads,
} = sharedData();
} = await sharedData();

const { initHighlighter } = await import("./highlight.mjs");
const highlighter = await initHighlighter();
Expand Down Expand Up @@ -227,7 +224,7 @@ const handlers = {
// pages are written, and it needs nothing from the main thread that
// dispatch has not already broadcast: it reads the offline tree from disk.
async helpArchive() {
const { skipOffline } = sharedData();
const { skipOffline } = await sharedData();
return helpArchiveStep({
src: path.relative(REPO_ROOT, ctx.srcRoot).replaceAll(path.sep, "/"),
offlineRoot: skipOffline ? null : `${ctx.destRoot}-offline`,
Expand All @@ -244,7 +241,7 @@ const handlers = {
// offline tree. It builds on threads of its own (search-index.mjs).
async searchIndex() {
if (ctx.opts.dryRun) return { entries: 0, workers: 0, bytes: 0 };
const { skipOffline } = sharedData();
const { skipOffline } = await sharedData();
return writeSearchIndex(ctx.destRoot, { offline: !skipOffline });
},

Expand Down
16 changes: 13 additions & 3 deletions builder/link-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,16 @@ export function settleFragments(pendingFragments, idsByTarget) {
// generator rather than being re-derived here.

const EXCLUDE = new Set(["book.html", "404.html"]);
// nav.html, the whole nav tree (template.mjs, renderNavTreePage), is no page
// of the site's: the sitemap and the search index leave it out, and it has no
// canonical. Only the tree's root one: a page elsewhere may have that name.
// The build hands it to the check with the redirect stubs, which leaves it out
// already; a tree read from disk does not say so.
const ROOT_EXCLUDE = new Set(["nav.html"]);

function excluded(rel) {
return EXCLUDE.has(path.posix.basename(rel)) || ROOT_EXCLUDE.has(rel);
}

// Every page (except the exclusions) should appear in sitemap.xml.
export function checkSitemap(xml, relFiles, basePath, optOut = null) {
Expand All @@ -885,7 +895,7 @@ export function checkSitemap(xml, relFiles, basePath, optOut = null) {

const issues = [];
for (const rel of relFiles) {
if (EXCLUDE.has(path.posix.basename(rel))) continue;
if (excluded(rel)) continue;
if (optOut?.has(rel)) continue;
const urlPath = deriveUrlPath(rel);
if (!sitemapPaths.has(urlPath)) issues.push(`${rel}: sitemap-missing: ${urlPath}`);
Expand All @@ -907,7 +917,7 @@ export function checkSearch(searchData, relFiles, basePath, optOut = null) {

const issues = [];
for (const rel of relFiles) {
if (EXCLUDE.has(path.posix.basename(rel))) continue;
if (excluded(rel)) continue;
if (optOut?.has(rel)) continue;
const urlPath = deriveUrlPath(rel);
if (!searchPageUrls.has(urlPath)) issues.push(`${rel}: search-missing: ${urlPath}`);
Expand All @@ -928,7 +938,7 @@ export function checkSearch(searchData, relFiles, basePath, optOut = null) {
export function checkCanonical(canonicalByRel, basePath) {
const issues = [];
for (const [rel, canonical] of canonicalByRel) {
if (EXCLUDE.has(path.posix.basename(rel))) continue;
if (excluded(rel)) continue;
const expected = (basePath || "") + deriveUrlPath(rel);

let canonicalPath;
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/check-src/assets/js/nav-tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Placeholder: the template references this unconditionally.
Loading