Title: Handle the case where one cannot execute JavaScript · Issue #37446 · nodejs/node · GitHub
Open Graph Title: Handle the case where one cannot execute JavaScript · Issue #37446 · nodejs/node
X Title: Handle the case where one cannot execute JavaScript · Issue #37446 · nodejs/node
Description: Re #30327 #37236 One (somewhat elaborate?) API for semver-minorly handling the inability to execute JS would be the following (somewhat introspective) API: typedef enum { node_api_reason_call_function, node_api_reason_throw_exception, no...
Open Graph Description: Re #30327 #37236 One (somewhat elaborate?) API for semver-minorly handling the inability to execute JS would be the following (somewhat introspective) API: typedef enum { node_api_reason_call_funct...
X Description: Re #30327 #37236 One (somewhat elaborate?) API for semver-minorly handling the inability to execute JS would be the following (somewhat introspective) API: typedef enum { node_api_reason_call_funct...
Opengraph URL: https://github.com/nodejs/node/issues/37446
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle the case where one cannot execute JavaScript","articleBody":"Re #30327 #37236\r\n\r\nOne (somewhat elaborate?) API for semver-minorly handling the inability to execute JS would be the following (somewhat introspective) API:\r\n\r\n```cpp\r\ntypedef enum {\r\n node_api_reason_call_function,\r\n node_api_reason_throw_exception,\r\n node_api_reason_open_handle_scope,\r\n node_api_reason_open_escapable_handle_scope,\r\n node_api_reason_open_callback_scope,\r\n ... // etc.\r\n} node_api_js_exec_failure_reason;\r\n\r\ntypedef napi_status (*node_api_js_exec_failure_callback)(\r\n napi_env env,\r\n node_api_js_exec_failure_reason reason,\r\n void* reason_data,\r\n void* user_data);\r\n\r\nNAPI_EXTERN napi_status\r\nnode_api_handle_js_execution_failure(\r\n napi_env env,\r\n node_api_js_exec_failure_callback exec_fail_cb,\r\n void* user_data);\r\n```\r\n\r\nThe add-on maintainer would attach a callback similarly to the `napi_set_instance_data` finalizer, which would get called whenever we would otherwise return `napi_cannot_call_into_js`. The callback would analyze the reason and the associated `reason_data` (which would be a pointer to a stack-allocated structure the type of which depends on `reason` – a little bit like `ioctl(2)`) and would return a `napi_status` that would then be passed as the return value to the original Node-API call.\r\n\r\nThis could be used to correct a return value of `napi_pending_exception` from a call to, say, `napi_call_function` into a return value of `napi_ok`.","author":{"url":"https://github.com/gabrielschulhof","@type":"Person","name":"gabrielschulhof"},"datePublished":"2021-02-19T18:41:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/37446/node/issues/37446"}
| 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:72e61186-f62d-c90f-d410-ab8f01e1b8cc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8252:7A367:10EF9A6:18AB5A7:6A4E3948 |
| html-safe-nonce | 6537dedd2e4ee53fb674d83ab5881df77c117b5fc7f27d8308df2a034c3f18d4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjUyOjdBMzY3OjEwRUY5QTY6MThBQjVBNzo2QTRFMzk0OCIsInZpc2l0b3JfaWQiOiI3NjU1MDUyMDA4ODEwNzU2NDI1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 079e6681e55af251d3716179331c4e3eb20cfc89845691fe9cdf09074fa4fbf8 |
| hovercard-subject-tag | issue:812249903 |
| 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/37446/issue_layout |
| twitter:image | https://opengraph.githubassets.com/40b51fa5cd55083fa2189900378bcd6aff3de5dba0f94f76e46ece2cce22dc85/nodejs/node/issues/37446 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/40b51fa5cd55083fa2189900378bcd6aff3de5dba0f94f76e46ece2cce22dc85/nodejs/node/issues/37446 |
| og:image:alt | Re #30327 #37236 One (somewhat elaborate?) API for semver-minorly handling the inability to execute JS would be the following (somewhat introspective) API: typedef enum { node_api_reason_call_funct... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gabrielschulhof |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| 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 | 42a6d378d7587a44c93aca255096cd66b7c8eb2d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width