[now-next] Make sure to 404 and clear cache header for invalid _next requests (#3801)

This handles an edge case where deeply nested dynamic routes were handling `_next` 404s that were cached forever since the immutable header we set isn't cleared after not matching on the filesystem.

I updated our cache-header fixture to check for this edge case also to make sure we don't regress on this
This commit is contained in:
JJ Kasper
2020-02-17 11:42:51 -06:00
committed by GitHub
parent 6e1a72f557
commit 5d1069d464
8 changed files with 58 additions and 0 deletions

View File

@@ -163,6 +163,21 @@ async function testDeployment(
);
}
});
} else if (probe.notResponseHeaders) {
Object.keys(probe.notResponseHeaders).forEach(header => {
const headerValue = resp.headers.get(header);
const expected = probe.notResponseHeaders[header];
if (headerValue === expected) {
const headers = Array.from(resp.headers.entries())
.map(([k, v]) => ` ${k}=${v}`)
.join('\n');
throw new Error(
`Page ${probeUrl} invalid page header ${header}.\n\n Did not expect: ${header}=${expected}.\nBut got ${headers}`
);
}
});
} else if (!probe.status) {
assert(false, 'probe must have a test condition');
}