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 all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -110,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
Expand Up @@ -79,6 +79,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
Expand Up @@ -625,7 +625,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 @@ -684,7 +684,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 @@ -748,7 +748,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 @@ -772,7 +772,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
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
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
2 changes: 1 addition & 1 deletion tests/unit/lib/functions/server.test.js
Expand Up @@ -18,7 +18,7 @@ test.before(async () => {
mkdirSync(functionsDirectory)

const mainFile = join(functionsDirectory, 'hello.js')
writeFileSync(mainFile, `exports.handler = (event) => ({ statusCode: 200, body: event.rawUrl })`)
writeFileSync(mainFile, `exports.handler = async (event) => ({ statusCode: 200, body: event.rawUrl })`)

const functionsRegistry = new FunctionsRegistry({
projectRoot,
Expand Down