Skip to content

Commit b223eb6

Browse files
author
Chris Wiechmann
committed
Test of ES-Connection improved
1 parent 91a79e2 commit b223eb6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • api-builder-plugin-fn-elasticsearch/src

api-builder-plugin-fn-elasticsearch/src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ async function getPlugin(pluginConfig, options) {
2424
// Create a connection to Elasticsearch on startup
2525
var client = new ElasticsearchClient(pluginConfig.elastic).client;
2626
// Validate a healthy connection
27-
if (!isDeveloperMode() && !client.isMocked) {
27+
if (!client.isMocked) {
2828
try {
2929
options.logger.info(`Validating connection to Elasticsearch: ${pluginConfig.elastic.nodes} ...`);
30-
await client.ping({requestTimeout: 3000});
30+
await client.ping();
3131
options.logger.info(`Connection to Elasticsearch: ${pluginConfig.elastic.nodes} successfully established.`);
3232
} catch (ex) {
33-
options.logger.error(`Connection to Elasticsearch: ${pluginConfig.elastic.nodes} not working. Error message: ${ex}`);
33+
options.logger.error(`Connection to Elasticsearch: ${pluginConfig.elastic.nodes} not working. Error message: ${JSON.stringify(ex)}`);
3434
// In development mode we allow to defer the obtaining of successfull Elasticsearch connection.
3535
// The promise is rejected only in production.
36-
return Promise.reject(ex);
36+
if(!isDeveloperMode()) {
37+
return Promise.reject(ex);
38+
}
3739
}
3840
}
3941
const sdk = new SDK({ pluginConfig });

0 commit comments

Comments
 (0)