GoogleCloudPlatform / GoogleCloudPlatform/synthetics-sdk-nodejs
Critical: runSyntheticHandler returns 200 in case of error thrown
- Dominant language
- TypeScript
- Stars
- 19
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've encountered a problem that seems very critical: runSyntheticHandler returns 200 even if an error is thrown.
## Impact
This is a critical bug, runSyntheticHandler is advertised in the official documentation and people might be missing on alerts created on `monitoring.googleapis.com/uptime_check/check_passed` which is always 100% even if the function fails.
## Reproduce
To reproduce:
```javascript
const functions = require("@google-cloud/functions-framework");
const {runSyntheticHandler} = require("@google-cloud/synthetics-sdk-api");
functions.http('test', runSyntheticHandler(async ({ logger, executionId }) => {
logger.info("foo");
throw new Error("some error");
}))
```
The result of calling the function is:
```
$ curl -i http://localhost:8080/
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 879
Date: Mon, 09 Mar 2026 13:34:59 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"synthetic_generic_result_v1":{"ok":false,"generic_error":{"error_type":"Error","error_message":"asd","function_name":"","file_path":"/home/somewhere/functions/myfunction/index.js","line":8,"stack_trace":"Error: asd\n at /home/somewhere/functions/myfunction/index.js:8:10\n at runSynthetic (/home/somewhere/node_modules/@google-cloud/synthetics-sdk-api/build/src/handlers.js:34:15)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /home/somewhere/node_modules/@google-cloud/synthetics-sdk-api/build/src/handlers.js:83:18"}},"runtime_metadata":{"@google-cloud/synthetics-sdk-api":"0.5.1"},"start_time":"2026-03-09T13:34:59.808Z","end_time":"2026-03-09T13:34:59.810Z"}
```
## Where is the bug
The bug is that this piece of the code that doesn't set `res.status(500)`: https://github.com/GoogleCloudPlatform/synthetics-sdk-nodejs/blob/71dbe8986118dc588d619a9c5a55b930def46157/packages/synthetics-sdk-api/src/handlers.ts#L50
## Expected
I would expect an error 500, otherwise the check_passed metric is always successful.
Contributor guide
Assessment
This issue has not been assessed yet.