mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 21:07:46 +00:00
[next] Re-enable shared lambdas by default (#4757)
This re-enables the shared lambdas optimization by default and also adds additional tests to ensure that when a `now.json` or `vercel.json` contains either `routes` or `functions` configs the shared lambda optimization is disabled. Additional test deployments done: - minimal `now.json` with `builds` config [deploy](https://shared-lambdas-tests-d646fsqju.vercel.app) - `now.json` with `functions` config [deploy](https://shared-lambdas-tests-ahnuosp4s.vercel.app) - `now.json` with `routes` config [deploy](https://shared-lambdas-tests-gulam3jda.vercel.app) - minimal `vercel.json` with `builds` config [deploy](https://shared-lambdas-tests-7ic7wzirs.vercel.app) - `vercel.json` with `functions` config [deploy](https://shared-lambdas-tests-7ic7wzirs.vercel.app) - `vercel.json` with `routes` config [deploy](https://shared-lambdas-tests-rja2391tq.vercel.app)
This commit is contained in:
@@ -57,6 +57,8 @@ async function testDeployment(
|
||||
|
||||
// we use json5 to allow comments for probes
|
||||
const nowJson = json5.parse(bodies[configName]);
|
||||
const uploadNowJson = nowJson.uploadNowJson;
|
||||
delete nowJson.uploadNowJson;
|
||||
|
||||
if (process.env.VERCEL_BUILDER_DEBUG) {
|
||||
if (!nowJson.build) {
|
||||
@@ -94,8 +96,14 @@ async function testDeployment(
|
||||
|
||||
bodies[configName] = Buffer.from(JSON.stringify(nowJson));
|
||||
delete bodies['probe.js'];
|
||||
const { deploymentId, deploymentUrl } = await nowDeploy(bodies, randomness);
|
||||
|
||||
const { deploymentId, deploymentUrl } = await nowDeploy(
|
||||
bodies,
|
||||
randomness,
|
||||
uploadNowJson
|
||||
);
|
||||
let nextBuildManifest;
|
||||
let deploymentLogs;
|
||||
|
||||
for (const probe of nowJson.probes || []) {
|
||||
console.log('testing', JSON.stringify(probe));
|
||||
@@ -104,6 +112,60 @@ async function testDeployment(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (probe.logMustContain || probe.logMustNotContain) {
|
||||
const shouldContain = !!probe.logMustContain;
|
||||
const toCheck = probe.logMustContain || probe.logMustNotContain;
|
||||
|
||||
if (probe.logMustContain && probe.logMustNotContain) {
|
||||
throw new Error(
|
||||
`probe can not check logMustContain and logMustNotContain in the same check`
|
||||
);
|
||||
}
|
||||
|
||||
if (!deploymentLogs) {
|
||||
try {
|
||||
const logsRes = await fetch(
|
||||
`https://vercel.com/api/v1/now/deployments/${deploymentId}/events?limit=-1`
|
||||
);
|
||||
|
||||
if (!logsRes.ok) {
|
||||
throw new Error(
|
||||
`fetching logs failed with status ${logsRes.status}`
|
||||
);
|
||||
}
|
||||
deploymentLogs = await logsRes.json();
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Failed to get deployment logs for probe: ${err.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let found = false;
|
||||
|
||||
for (const log of deploymentLogs) {
|
||||
if (log.text && log.text.includes(toCheck)) {
|
||||
if (shouldContain) {
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Expected deployment logs not to contain ${toCheck}, but found ${log.text}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && shouldContain) {
|
||||
throw new Error(
|
||||
`Expected deployment logs to contain ${toCheck}, it was not found`
|
||||
);
|
||||
} else {
|
||||
console.log('finished testing', JSON.stringify(probe));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const nextScriptIndex = probe.path.indexOf('__NEXT_SCRIPT__(');
|
||||
|
||||
if (nextScriptIndex > -1) {
|
||||
|
||||
Reference in New Issue
Block a user