Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Vercel serverless adapter logs too much #8581

Merged
merged 9 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/fluffy-dodos-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---

log only once in serverless adapter
46 changes: 25 additions & 21 deletions packages/integrations/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ You can set functionPerRoute: false to prevent surpassing the limit.`
const filesToInclude = includeFiles?.map((file) => new URL(file, _config.root)) || [];
filesToInclude.push(...extraFilesToInclude);

getRuntime(true);
rishi-raj-jain marked this conversation as resolved.
Show resolved Hide resolved

// Multiple entrypoint support
if (_entryPoints.size) {
const getRouteFuncName = (route: RouteData) => route.component.replace('src/pages/', '');
Expand Down Expand Up @@ -312,29 +314,31 @@ You can set functionPerRoute: false to prevent surpassing the limit.`
};
}

function getRuntime() {
function getRuntime(verbose?: boolean) {
rishi-raj-jain marked this conversation as resolved.
Show resolved Hide resolved
const version = process.version.slice(1); // 'v16.5.0' --> '16.5.0'
const major = version.split('.')[0]; // '16.5.0' --> '16'
const support = SUPPORTED_NODE_VERSIONS[major];
if (support === undefined) {
console.warn(
`[${PACKAGE_NAME}] The local Node.js version (${major}) is not supported by Vercel Serverless Functions.`
);
console.warn(`[${PACKAGE_NAME}] Your project will use Node.js 18 as the runtime instead.`);
console.warn(`[${PACKAGE_NAME}] Consider switching your local version to 18.`);
return 'nodejs18.x';
rishi-raj-jain marked this conversation as resolved.
Show resolved Hide resolved
}
if (support.status === 'deprecated') {
console.warn(
`[${PACKAGE_NAME}] Your project is being built for Node.js ${major} as the runtime.`
);
console.warn(
`[${PACKAGE_NAME}] This version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${new Intl.DateTimeFormat(
undefined,
{ dateStyle: 'long' }
).format(support.removal)}.`
);
console.warn(`[${PACKAGE_NAME}] Consider upgrading your local version to 18.`);
if (verbose) {
const support = SUPPORTED_NODE_VERSIONS[major];
if (support === undefined) {
console.warn(
`[${PACKAGE_NAME}] The local Node.js version (${major}) is not supported by Vercel Serverless Functions.`
);
console.warn(`[${PACKAGE_NAME}] Your project will use Node.js 18 as the runtime instead.`);
console.warn(`[${PACKAGE_NAME}] Consider switching your local version to 18.`);
return 'nodejs18.x';
}
if (support.status === 'deprecated') {
console.warn(
`[${PACKAGE_NAME}] Your project is being built for Node.js ${major} as the runtime.`
);
console.warn(
`[${PACKAGE_NAME}] This version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${new Intl.DateTimeFormat(
undefined,
{ dateStyle: 'long' }
).format(support.removal)}.`
);
console.warn(`[${PACKAGE_NAME}] Consider upgrading your local version to 18.`);
}
}
return `nodejs${major}.x`;
}
Loading