Skip to content

Commit

Permalink
fix: safely check function result (#6219)
Browse files Browse the repository at this point in the history
* fix: safely check function result

* refactor: use optional chaining operator
  • Loading branch information
eduardoboucas authored Nov 28, 2023
1 parent 85b29c6 commit c0c5f4b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/functions/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const createHandler = function (options) {
const { error, result } = await func.invoke(event, clientContext)

// check for existence of metadata if this is a builder function
if (/^\/.netlify\/(builders)/.test(request.path) && (!result.metadata || !result.metadata.builder_function)) {
if (/^\/.netlify\/(builders)/.test(request.path) && !result?.metadata?.builder_function) {
response.status(400).send({
message:
'Function is not an on-demand builder. See https://ntl.fyi/create-builder for how to convert a function to a builder.',
Expand Down

1 comment on commit c0c5f4b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Dependency count: 1,396
  • Package size: 404 MB
  • Number of ts-expect-error directives: 0

Please sign in to comment.