From 178bb5118f8615ac7ee5abef0986df316da9e6bb Mon Sep 17 00:00:00 2001 From: neta Date: Mon, 20 Nov 2017 21:41:56 +0200 Subject: [PATCH 1/5] src: updating status message list for napi_handle_scope_mismatch --- src/node_api.cc | 7 ++++--- tools/doc/node_modules/js-yaml/index.js | 12 ++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/node_api.cc b/src/node_api.cc index ad922d9ad195db..362ae75d18c1b4 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -898,7 +898,8 @@ const char* error_messages[] = {nullptr, "Unknown failure", "An exception is pending", "The async work item was cancelled", - "napi_escape_handle already called on scope"}; + "napi_escape_handle already called on scope", + "invalid handle scope usage"}; static inline napi_status napi_clear_last_error(napi_env env) { env->last_error.error_code = napi_ok; @@ -929,9 +930,9 @@ napi_status napi_get_last_error_info(napi_env env, // We don't have a napi_status_last as this would result in an ABI // change each time a message was added. static_assert( - node::arraysize(error_messages) == napi_escape_called_twice + 1, + node::arraysize(error_messages) == napi_handle_scope_mismatch, "Count of error messages must match count of error values"); - CHECK_LE(env->last_error.error_code, napi_escape_called_twice); + CHECK_LE(env->last_error.error_code, napi_handle_scope_mismatch); // Wait until someone requests the last error information to fetch the error // message string diff --git a/tools/doc/node_modules/js-yaml/index.js b/tools/doc/node_modules/js-yaml/index.js index 620bc293ffe032..13744352448b84 100644 --- a/tools/doc/node_modules/js-yaml/index.js +++ b/tools/doc/node_modules/js-yaml/index.js @@ -1,15 +1,7 @@ 'use strict'; -// Hack to load the js-yaml module from eslint. -// No other reason than that it’s huge. -const path = require('path'); +var yaml = require('./lib/js-yaml.js'); -const realJSYaml = path.resolve( - __dirname, '..', '..', '..', // tools/ - 'eslint', - 'node_modules', - 'js-yaml' -); -module.exports = require(realJSYaml); +module.exports = yaml; From 0301123b3cf9b53635b9805132d4e1b12e7bea9e Mon Sep 17 00:00:00 2001 From: neta Date: Mon, 20 Nov 2017 22:53:08 +0200 Subject: [PATCH 2/5] src: fixing the size of error_messages to last_error+1 --- src/node_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_api.cc b/src/node_api.cc index 362ae75d18c1b4..b0b1c4e48a08eb 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -930,7 +930,7 @@ napi_status napi_get_last_error_info(napi_env env, // We don't have a napi_status_last as this would result in an ABI // change each time a message was added. static_assert( - node::arraysize(error_messages) == napi_handle_scope_mismatch, + node::arraysize(error_messages) == napi_handle_scope_mismatch + 1, "Count of error messages must match count of error values"); CHECK_LE(env->last_error.error_code, napi_handle_scope_mismatch); From ad4bd24d27bbe8b479b8cf4a8629fc4001cf8bf2 Mon Sep 17 00:00:00 2001 From: neta Date: Mon, 20 Nov 2017 23:19:01 +0200 Subject: [PATCH 3/5] src: capitalize error message- Invalid handle scope usage --- src/node_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_api.cc b/src/node_api.cc index b0b1c4e48a08eb..55fcb070ad89f3 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -899,7 +899,7 @@ const char* error_messages[] = {nullptr, "An exception is pending", "The async work item was cancelled", "napi_escape_handle already called on scope", - "invalid handle scope usage"}; + "Invalid handle scope usage"}; static inline napi_status napi_clear_last_error(napi_env env) { env->last_error.error_code = napi_ok; From 9bbfe399efe1f41cc1daa3852131a7a8eb840e4a Mon Sep 17 00:00:00 2001 From: neta Date: Mon, 20 Nov 2017 23:19:01 +0200 Subject: [PATCH 4/5] src: capitalize error message- Invalid handle scope usage --- src/node_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_api.cc b/src/node_api.cc index b0b1c4e48a08eb..55fcb070ad89f3 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -899,7 +899,7 @@ const char* error_messages[] = {nullptr, "An exception is pending", "The async work item was cancelled", "napi_escape_handle already called on scope", - "invalid handle scope usage"}; + "Invalid handle scope usage"}; static inline napi_status napi_clear_last_error(napi_env env) { env->last_error.error_code = napi_ok; From 774ddd188373b5eac59d7c0369778339a96add62 Mon Sep 17 00:00:00 2001 From: neta-kedem Date: Tue, 21 Nov 2017 21:59:57 +0200 Subject: [PATCH 5/5] tools: undid the change in the index file --- tools/doc/node_modules/js-yaml/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/doc/node_modules/js-yaml/index.js b/tools/doc/node_modules/js-yaml/index.js index 13744352448b84..620bc293ffe032 100644 --- a/tools/doc/node_modules/js-yaml/index.js +++ b/tools/doc/node_modules/js-yaml/index.js @@ -1,7 +1,15 @@ 'use strict'; +// Hack to load the js-yaml module from eslint. +// No other reason than that it’s huge. -var yaml = require('./lib/js-yaml.js'); +const path = require('path'); +const realJSYaml = path.resolve( + __dirname, '..', '..', '..', // tools/ + 'eslint', + 'node_modules', + 'js-yaml' +); -module.exports = yaml; +module.exports = require(realJSYaml);