Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-yx committed Feb 13, 2019
2 parents 9321479 + 879211d commit 450f395
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ The goal is to make it easy to write Lambda's with transpiled JS/TypeScript feat

Netlify-Lambda uses webpack to bundle up your functions and their dependencies for you, however this is not the only approach. If you have native node modules (or other dependencies that dont expect to be bundled like [the Firebase SDK](https://github.com/netlify/netlify-lambda/issues/112)) then you may want to try the zipping approach.

We have recently soft released a new library to do this for you: https://github.com/netlify/zip-it-and-ship-it. This is integrated into the Netlify CLI. There is [more documentation here](https://www.netlify.com/docs/cli/#unbundled-javascript-function-deploys) in the official CLI docs and support is available through [our regular channels](https://www.netlify.com/support/).
We have recently integrated this functionality ([zip-it-and-ship-it](https://github.com/netlify/zip-it-and-ship-it)) into the Netlify CLI. Check the [documentation here](https://www.netlify.com/docs/cli/#unbundled-javascript-function-deploys) in the official CLI docs and support is available through [our regular channels](https://www.netlify.com/support/). The current drawback of this approach is no ability to serve these zipped functions locally, although we are working on this.

<details>
<summary><b>DIY zipping</b></summary>
<summary><b>A bit information on manual zipping</b></summary>

Read [here](https://www.netlify.com/blog/2018/09/14/forms-and-functions/) and [here for instructions](https://github.com/DavidWells/function-zips/) (more examples [here](https://github.com/netlify/function-bundling-example))
You can still zip up and deploy functions by yourself, as has always been the case with Netlify Functions. Read [here](https://www.netlify.com/blog/2018/09/14/forms-and-functions/) and [here for instructions](https://github.com/DavidWells/function-zips/) (more examples [here](https://github.com/netlify/function-bundling-example))
</details>

Look out for more announcements on this in coming months.
Expand Down
16 changes: 12 additions & 4 deletions lib/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,20 @@ function createHandler(dir, static, timeout) {
{ clientContext: buildClientContext(request.headers) || {} },
callback
);

var invocationTimeoutRef = null

Promise.race([
promiseCallback(promise, callback),
setTimeout(function() {
handleInvocationTimeout(response, timeout)
}, timeout * 1000)
])
new Promise(function(resolve) {
invocationTimeoutRef = setTimeout(function() {
handleInvocationTimeout(response, timeout)
resolve()
}, timeout * 1000)
})
]).finally(() => {
clearTimeout(invocationTimeoutRef)
})
};
}

Expand Down

0 comments on commit 450f395

Please sign in to comment.