From 807229709051ea167cb40c15b70c762b2904a546 Mon Sep 17 00:00:00 2001 From: Harm Matthias Harms Date: Mon, 8 Sep 2025 16:31:45 +0200 Subject: [PATCH] Fix process exit code type error Since the node20 update process.exit(!!err) is not working anymore and throwing `TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type boolean (false)`, because the boolean is not converted to a number anymore. --- scripts/drop_index.js | 4 ++-- scripts/update_settings.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/drop_index.js b/scripts/drop_index.js index 100ad2ec..2cf76065 100644 --- a/scripts/drop_index.js +++ b/scripts/drop_index.js @@ -13,7 +13,7 @@ function drop() { const req = { index: config.schema.indexName }; client.indices.delete(req, (err, res) => { console.log('\n[delete mapping]', '\t', config.schema.indexName, err || '\t', res); - process.exit(!!err); + process.exit(err ? 1 : 0); }); } @@ -39,4 +39,4 @@ function fail() { function isForced() { return process.argv.length > 2 && ['--force-yes', '-f'].indexOf(process.argv[2]) > -1; -} \ No newline at end of file +} diff --git a/scripts/update_settings.js b/scripts/update_settings.js index 22d7b9c5..4ae24a41 100644 --- a/scripts/update_settings.js +++ b/scripts/update_settings.js @@ -6,19 +6,19 @@ var schema = require('../schema'); var _index = config.schema.indexName; // Error: ElasticsearchIllegalArgumentException[can't change the number of shards for an index -if( schema.settings.hasOwnProperty('index') && - schema.settings.index.hasOwnProperty('number_of_shards') ){ +if (schema.settings.hasOwnProperty('index') && + schema.settings.index.hasOwnProperty('number_of_shards')) { delete schema.settings.index.number_of_shards; delete schema.settings.index.number_of_replicas; } -client.indices.close( { index: _index }, function( err, res ){ - console.log( '[close index]', '\t', _index, err || '\t', res ); - client.indices.putSettings( { index: _index, body: schema.settings }, function( err, res ){ - console.log( '[put settings]', '\t', _index, err || '\t', res ); - client.indices.open( { index: _index }, function( err, res ){ - console.log( '[open index]', '\t', _index, err || '\t', res ); - process.exit( !!err ); +client.indices.close({ index: _index }, function (err, res) { + console.log('[close index]', '\t', _index, err || '\t', res); + client.indices.putSettings({ index: _index, body: schema.settings }, function (err, res) { + console.log('[put settings]', '\t', _index, err || '\t', res); + client.indices.open({ index: _index }, function (err, res) { + console.log('[open index]', '\t', _index, err || '\t', res); + process.exit(err ? 1 : 0); }); }); });