Skip to content

Commit 2a10a8b

Browse files
author
Peter Bengtsson
authored
don't fail in FailBot in search API if nothing to report (github#30546)
1 parent 896dc23 commit 2a10a8b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

middleware/api/search.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,19 @@ router.get(
257257
if (process.env.NODE_ENV === 'development') {
258258
console.error('Error calling getSearchResults()', error)
259259
} else {
260-
await Promise.all(
261-
FailBot.report(error, {
262-
url: req.url,
263-
indexName,
264-
query,
265-
page,
266-
size,
267-
debug,
268-
sort,
269-
})
270-
)
260+
const reports = FailBot.report(error, {
261+
url: req.url,
262+
indexName,
263+
query,
264+
page,
265+
size,
266+
debug,
267+
sort,
268+
})
269+
// It might be `undefined` if no backends are configured which
270+
// is likely when using production NODE_ENV on your laptop
271+
// where you might not have a HATSTACK_URL configured.
272+
if (reports) await Promise.all(reports)
271273
}
272274
res.status(500).send(error.message)
273275
}

0 commit comments

Comments
 (0)