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

[node] add maxDuration config support for vc node deployments #10028

Merged
merged 9 commits into from Jun 5, 2023
7 changes: 7 additions & 0 deletions packages/cli/src/util/build/write-build-result.ts
Expand Up @@ -371,6 +371,13 @@ async function writeLambda(
}

const memory = functionConfiguration?.memory ?? lambda.memory;

if (functionConfiguration?.maxDuration && lambda.maxDuration) {
throw new Error(
`Cannot specify both \`maxDuration\` in \`vercel.json\` and \`${path}\``
ecklf marked this conversation as resolved.
Show resolved Hide resolved
);
}

const maxDuration = functionConfiguration?.maxDuration ?? lambda.maxDuration;

const config = {
Expand Down
3 changes: 3 additions & 0 deletions packages/node/src/index.ts
Expand Up @@ -506,6 +506,9 @@ export const build: BuildV3 = async ({
shouldAddSourcemapSupport,
awsLambdaHandler,
supportsResponseStreaming,
...(staticConfig?.maxDuration
? { maxDuration: staticConfig.maxDuration }
: {}),
ecklf marked this conversation as resolved.
Show resolved Hide resolved
});
}

Expand Down
1 change: 1 addition & 0 deletions packages/static-config/test/fixtures/deno.ts
Expand Up @@ -4,6 +4,7 @@ import { readerFromStreamReader } from 'https://deno.land/std@0.107.0/io/streams
export const config = {
runtime: 'deno',
location: 'https://example.com/page',
maxDuration: 60
};

export default async ({ request }: Deno.RequestEvent) => {
Expand Down
1 change: 1 addition & 0 deletions packages/static-config/test/fixtures/node.js
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs';
export const config = {
runtime: 'nodejs',
memory: 1024,
maxDuration: 60,
};

export default function (req, res) {
Expand Down
2 changes: 2 additions & 0 deletions packages/static-config/test/index.test.ts
Expand Up @@ -9,6 +9,7 @@ describe('getConfig()', () => {
const config = getConfig(project, sourcePath);
expect(config).toMatchInlineSnapshot(`
{
"maxDuration": 60,
"memory": 1024,
"runtime": "nodejs",
}
Expand All @@ -27,6 +28,7 @@ describe('getConfig()', () => {
expect(config).toMatchInlineSnapshot(`
{
"location": "https://example.com/page",
"maxDuration": 60,
"runtime": "deno",
}
`);
Expand Down
2 changes: 2 additions & 0 deletions packages/static-config/test/swc.test.ts
Expand Up @@ -56,6 +56,7 @@ describe('getConfig for swc', () => {
const config = getConfig(ast, BaseFunctionConfigSchema);
expect(config).toMatchInlineSnapshot(`
{
"maxDuration": 60,
"memory": 1024,
"runtime": "nodejs",
}
Expand All @@ -73,6 +74,7 @@ describe('getConfig for swc', () => {
expect(config).toMatchInlineSnapshot(`
{
"location": "https://example.com/page",
"maxDuration": 60,
"runtime": "deno",
}
`);
Expand Down