Skip to content

Commit

Permalink
fix: Vercel serverless adapter logs too much (#8581)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Raj Jain authored Sep 18, 2023
1 parent 0586e20 commit d0e513f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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
15 changes: 13 additions & 2 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);

validateRuntime();

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

function getRuntime() {
function validateRuntime() {
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];
Expand All @@ -322,7 +324,7 @@ function getRuntime() {
);
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';
return;
}
if (support.status === 'deprecated') {
console.warn(
Expand All @@ -336,5 +338,14 @@ function getRuntime() {
);
console.warn(`[${PACKAGE_NAME}] Consider upgrading your local version to 18.`);
}
}

function getRuntime() {
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) {
return 'nodejs18.x';
}
return `nodejs${major}.x`;
}

0 comments on commit d0e513f

Please sign in to comment.