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(deps): update dependency lambda-local to v2.0.2 #4443

Merged
merged 18 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 16 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
54 changes: 13 additions & 41 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
"Cassidy Williams (https://twitter.com/cassidoo)",
"Charlie Depman <cdepman@gmail.com> (depman.dev)",
"Charlie Depman <cdepman@gmail.com> (depman.dev)",
"Charlie Depman <cdepman@gmail.com> (depman.dev)",
"Cole Bosmann",
"Dan Croak (https://twitter.com/croaky)",
"Dan Loewenherz <dan@lionheartsw.com> (https://twitter.com/dwlz)",
"Daniel Woelfel <dwwoelfel@gmail.com> (https://twitter.com/danielwoelfel)",
"Dave Ackerman <dmackerman@gmail.com>",
"David Calavera <david@netlify.com> (https://twitter.com/calavera)",
"David Lemler <dlemler@pm.me> (https://twitter.com/davidlemlerm)",
Expand All @@ -46,7 +48,8 @@
"Gergely Nemeth (https://twitter.com/nthgergo)",
"HonkingGoose",
"Ian Martorell <ianmartorell@gmail.com>",
"Ibrahima",
"Ibrahima G. Coulibaly <ibracool99@gmail.com>",
"Jackie Macharia (wangoimacharia.dev)",
"Jacob Schatz",
"Jake Jarvis <jake@jarv.is> (https://twitter.com/jakejarvis)",
"Jakob Warkotsch <j.warkotsch@gmail.com>",
Expand All @@ -68,6 +71,7 @@
"Kyle Rollins <kyleblankrollins@gmail.com> (kyleblankrollins.com)",
"Leon Hennings",
"Liran Tal <liran.tal@gmail.com> (https://twitter.com/liran_tal)",
"Louis DeScioli (https://twitter.com/descioli)",
"Lukas Holzer <lukas.holzer@netlify.com> (https://twitter.com/luka5c0m)",
"Marcus Weiner",
"Mark Bello <mark@markbello.dev> (https://markbello.dev)",
Expand Down Expand Up @@ -106,6 +110,7 @@
"Sergii Zinkevych",
"Shawn Erquhart <shawn@erquh.art>",
"Shawn Makinson (http://smakinson.github.io)",
"Simon Knott <info@simonknott.de> (https://twitter.com/skn0tt)",
"Souma Suzuki <subayai.kobashiri@gmail.com>",
"Sébastien Chopin <seb@nuxtjs.com> (https://twitter.com/Atinux)",
"Takumi Hirunuma <m.111_t.1230_nittc@outlook.com> (https://twitter.com/mg111_)",
Expand Down
5 changes: 5 additions & 0 deletions src/lib/functions/synchronous.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const validateLambdaResponse = (lambdaResponse) => {
if (lambdaResponse === undefined) {
return { error: 'lambda response was undefined. check your function code again' }
}
if (lambdaResponse === null) {
return {
error: 'no lambda response. check your function code again. make sure to return a promise or use the callback.',
}
}
if (!Number(lambdaResponse.statusCode)) {
return {
error: `Your function response must have a numerical statusCode. You gave: $ ${lambdaResponse.statusCode}`,
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/20.command.functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ test('should serve helpful tips and tricks', async (t) => {
content: `
const { schedule } = require('@netlify/functions')

module.exports.handler = schedule('@daily', () => {
module.exports.handler = schedule('@daily', async () => {
return {
statusCode: 200,
body: "hello world"
Expand Down Expand Up @@ -683,7 +683,7 @@ test('should emulate next_run for scheduled functions', async (t) => {
path: 'functions/hello-world.js',
content: `
const { schedule } = require('@netlify/functions')
module.exports.handler = schedule("@daily", (event) => {
module.exports.handler = schedule("@daily", async (event) => {
const { next_run } = JSON.parse(event.body)
return {
statusCode: !!next_run ? 200 : 400,
Expand Down Expand Up @@ -747,7 +747,7 @@ test('should detect file changes to scheduled function', async (t) => {
.withContentFile({
path: 'functions/hello-world.js',
content: `
module.exports.handler = () => {
module.exports.handler = async () => {
return {
statusCode: 200
}
Expand All @@ -771,7 +771,7 @@ test('should detect file changes to scheduled function', async (t) => {
content: `
const { schedule } = require('@netlify/functions')

module.exports.handler = schedule("@daily", () => {
module.exports.handler = schedule("@daily", async () => {
return {
statusCode: 200,
body: "test"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/330.serving-functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ testMatrix.forEach(({ args }) => {
path: 'functions/hello/index.js',
content: `
const response = require("./dist")
exports.handler = () => ({
exports.handler = async () => ({
statusCode: 200,
body: response
})`,
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/400.command.dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ testMatrix.forEach(({ args }) => {
})
})

test(testName('should replicate Lambda behaviour for synchronous return values', args), async (t) => {
await withSiteBuilder('site-replicate-aws-sync-behaviour', async (builder) => {
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
path: 'env.js',
handler: () => ({
statusCode: 200,
}),
})

await builder.buildAsync()

await withDevServer({ cwd: builder.directory, args }, async (server) => {
const response = await got(`${server.url}/.netlify/functions/env`, {
throwHttpErrors: false,
})
t.true(response.body.startsWith('no lambda response.'))
})
})
})

test(testName('should redirect using a wildcard when set in netlify.toml', args), async (t) => {
await withSiteBuilder('site-with-redirect-function', async (builder) => {
builder
Expand Down