Title: sqlite: custom function callback errors should be reported to sqlite API · Issue #56772 · nodejs/node · GitHub
Open Graph Title: sqlite: custom function callback errors should be reported to sqlite API · Issue #56772 · nodejs/node
X Title: sqlite: custom function callback errors should be reported to sqlite API · Issue #56772 · nodejs/node
Description: In the callback wrapper for user-provided functions (ie. those added with DatabaseSync#function()), error conditions in the JS callback result in an early return to the sqlite API: node/src/node_sqlite.cc Lines 202 to 207 in 1c7c32f Mayb...
Open Graph Description: In the callback wrapper for user-provided functions (ie. those added with DatabaseSync#function()), error conditions in the JS callback result in an early return to the sqlite API: node/src/node_sq...
X Description: In the callback wrapper for user-provided functions (ie. those added with DatabaseSync#function()), error conditions in the JS callback result in an early return to the sqlite API: node/src/node_sq...
Opengraph URL: https://github.com/nodejs/node/issues/56772
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlite: custom function callback errors should be reported to sqlite API","articleBody":"In the callback wrapper for user-provided functions (ie. those added with `DatabaseSync#function()`), error conditions in the JS callback result in an early return to the sqlite API:\n\nhttps://github.com/nodejs/node/blob/1c7c32f96128ac2ae5472dd2da425d9cf638b453/src/node_sqlite.cc#L202-L207\n\nIn sqlite, this results in the return value of the user-defined function being implicitly set to NULL. It does not signal an error condition from the callback.\n\nThis raises the potential for user function callbacks to encounter error conditions, but still cause side-effects in sqlite. As a basic example:\n\n```js\nconst sqlite = require('node:sqlite');\nconst db = new sqlite.DatabaseSync(':memory:');\ndb.exec('CREATE TABLE test (id NUMBER NOT NULL PRIMARY KEY, data TEXT)');\n\n// create a user-defined function that throws\ndb.function('MYFUNC', function () { throw new Error('MYFUNC callback threw!') });\n\n// fill table with arbitrary data\n{\n const stmt = db.prepare('INSERT INTO test (id, data) VALUES (?, ?)');\n for (let i = 0; i \u003c 10; i++) {\n stmt.run(i, Math.random().toString());\n }\n}\n\ndb.prepare('SELECT * FROM test').all();\n// [\n// [Object: null prototype] { id: 0, data: '0.5786694350792139' },\n// [Object: null prototype] { id: 1, data: '0.9442753197210123' },\n// ...\n// ]\n\ndb.exec('UPDATE test SET data = MYFUNC()');\n// Uncaught Error: MYFUNC callback threw!\n\ndb.prepare('SELECT * FROM test').all();\n// [\n// [Object: null prototype] { id: 0, data: null },\n// [Object: null prototype] { id: 1, data: null },\n// ...\n// ]\n```\n\nError conditions in the user function callback should call [`sqlite3_result_error()`](https://www.sqlite.org/c3ref/result_blob.html) in order to signal the sqlite API that an error has occurred and that the query should be aborted.","author":{"url":"https://github.com/Renegade334","@type":"Person","name":"Renegade334"},"datePublished":"2025-01-26T15:21:10Z","url":"https://github.com/nodejs/node/issues/56772"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e41355bd-d21d-3f4d-4929-e4b780e9d508 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C822:3714B8:9098F1:C6CB2C:6B044F21 |
| html-safe-nonce | 546818c0ed6fc81264cfa58e7c77c10e23de90d4bc95a00dbe2e6d31314034f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODIyOjM3MTRCODo5MDk4RjE6QzZDQjJDOjZCMDQ0RjIxIiwidmlzaXRvcl9pZCI6IjI5NDg4ODMwMDYzMDUzNTc2MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c98d1958e0fa7184faf88d05c2a1f76c96dd0f8ec74ae2e6d2876026b41fee94 |
| hovercard-subject-tag | issue:2811617703 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/56772/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b8099d5dfea6901c46e90dcb4ecaa694e80d022dfff4ca61a7bbc8eee52b8de8/nodejs/node/issues/56772 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b8099d5dfea6901c46e90dcb4ecaa694e80d022dfff4ca61a7bbc8eee52b8de8/nodejs/node/issues/56772 |
| og:image:alt | In the callback wrapper for user-provided functions (ie. those added with DatabaseSync#function()), error conditions in the JS callback result in an early return to the sqlite API: node/src/node_sq... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Renegade334 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 002aa6b95ffa730b0aec436a5c383f536ad677284e60056037fb120afe37b730 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 059f24c781e3a0d7df3f27a97da0e93fab06ae39 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width