Skip to content

Commit

Permalink
[8.9] fix(NA): apply ipv4 first dns result order for worker threads (#…
Browse files Browse the repository at this point in the history
…163484) (#163512)

# Backport

This will backport the following commits from `main` to `8.9`:
- [fix(NA): apply ipv4 first dns result order for worker threads
(#163484)](#163484)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tiago
Costa","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-08-09T15:49:57Z","message":"fix(NA):
apply ipv4 first dns result order for worker threads (#163484)\n\nThis
PR is a follow up of https://github.com/elastic/kibana/pull/163025\r\nas
we discover the initial fix doesn't apply correctly to
working\r\nthreads during
development.","sha":"f4856f74784cf5ca2094f2f54a6d86f2aff3335a","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","backport:all-open","v8.10.0"],"number":163484,"url":"https://github.com/elastic/kibana/pull/163484","mergeCommit":{"message":"fix(NA):
apply ipv4 first dns result order for worker threads (#163484)\n\nThis
PR is a follow up of https://github.com/elastic/kibana/pull/163025\r\nas
we discover the initial fix doesn't apply correctly to
working\r\nthreads during
development.","sha":"f4856f74784cf5ca2094f2f54a6d86f2aff3335a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/163484","number":163484,"mergeCommit":{"message":"fix(NA):
apply ipv4 first dns result order for worker threads (#163484)\n\nThis
PR is a follow up of https://github.com/elastic/kibana/pull/163025\r\nas
we discover the initial fix doesn't apply correctly to
working\r\nthreads during
development.","sha":"f4856f74784cf5ca2094f2f54a6d86f2aff3335a"}}]}]
BACKPORT-->
  • Loading branch information
mistic authored Aug 9, 2023
1 parent 7413e8a commit d781e42
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/setup_node_env/dns_ipv4_first.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

// enables Node 16 default DNS lookup behavior for the current thread
require('dns').setDefaultResultOrder('ipv4first');

// overrides current process node options, so it can be restored in worker threads too
process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS || ''} --dns-result-order=ipv4first`;
4 changes: 4 additions & 0 deletions src/setup_node_env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@

// development env setup includes babel/register after the env is initialized
require('./setup_env');

// restore < Node 16 default DNS lookup behavior
require('./dns_ipv4_first');

require('@kbn/babel-register').install();
require('./polyfill');

0 comments on commit d781e42

Please sign in to comment.