Skip to content

Commit 40eaa1c

Browse files
trialclaude
andcommitted
fix(plugin): review of 0.101.0 -- an entity registry that throws is logged and the probe pass carries on; v0.101.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 39c4878 commit 40eaa1c

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎packages/plugin/src/util/changeProbe.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,11 +1497,18 @@ export const runProbePass = async ({
14971497
// THE ENTITY'S CANONICAL, as the origin's endpoint names it now (util/entity.js). Before the baseline
14981498
// logic, because it is a statement about the origin, not about this row's history: a re-baselined or a
14991499
// changed row reports its product's canonical all the same. Only from an ARMED mapped field — one the
1500-
// mapping guard disarmed is suspected of being mapped wrong, and must not file targets.
1500+
// mapping guard disarmed is suspected of being mapped wrong, and must not file targets. The hook is an
1501+
// add-on to the pass, so its failure is logged and the row carries on: it must never end the pass.
15011502
if (onCanonical) {
15021503
const field = canonicalFieldOf(rule);
15031504
const slots = field && (!guard || guard.isArmed(rule, field)) ? valuesOf() : null;
1504-
if (slots) await onCanonical({ url: row.url, value: slots[field.slot] });
1505+
if (slots) {
1506+
try {
1507+
await onCanonical({ url: row.url, value: slots[field.slot] });
1508+
} catch (e) {
1509+
logger.warn?.(`[prerender] change-probe: entity registry failed for ${row.url}: ${e?.message ?? String(e)}`);
1510+
}
1511+
}
15051512
}
15061513

15071514
// RULE CHANGED, NOT CONTENT. A baseline is only comparable to an observation made the same

‎packages/plugin/test/changeProbe.test.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,6 +2820,33 @@ test('the entity registry is told the canonical slot of every probe that answere
28202820
assert.deepEqual(told, []);
28212821
});
28222822

2823+
test('an entity registry that throws, synchronously or not, costs the pass nothing', async () => {
2824+
const signature = await apiSig({ seoUrl: '/product/prd-a/new-spelling.jsp' });
2825+
for (const fail of [
2826+
() => {
2827+
throw new Error('sync');
2828+
},
2829+
async () => {
2830+
throw new Error('async');
2831+
},
2832+
]) {
2833+
const told = [];
2834+
const onCanonical = (observation) => (observation.url === URL_A ? fail() : told.push(observation.url));
2835+
const { stats, written } = await runMappedPass({
2836+
rows: [row(URL_A), row(URL_B)],
2837+
answers: { [URL_A]: signature, [URL_B]: signature },
2838+
onCanonical,
2839+
});
2840+
assert.deepEqual(told, [URL_B], 'the next row is still probed and reported');
2841+
assert.deepEqual(
2842+
written.map(({ url }) => url),
2843+
[URL_A, URL_B],
2844+
'the failing row still seeds its baseline'
2845+
);
2846+
assert.equal(stats.failed, 0);
2847+
}
2848+
});
2849+
28232850
test('CAUGHT UP: the origin changed and the page ALREADY shows the new value -> baseline moves, nothing triggered', async () => {
28242851
// A cadence render landed after the rename: re-rendering again would buy nothing.
28252852
const before = await apiSig();

0 commit comments

Comments
 (0)