@@ -26,23 +26,25 @@ function getEncryptionInit(key: Buffer): string {
2626 return JSON . stringify ( request ) + '\n'
2727}
2828
29+ // use dynamic linking to let node binary
30+ // pick up GLIBC >= 2.28
2931const al2Config = {
3032 path : '/opt/vsc-sysroot/lib64/ld-linux-x86-64.so.2' ,
3133 args : [ '--library-path' , '/opt/vsc-sysroot/lib64' ] ,
3234}
33-
35+ function createNodeProcess ( nodePath : string , args : string [ ] ) {
36+ return new ChildProcess (
37+ isAmazonInternalOs ( ) ? al2Config . path : nodePath ,
38+ isAmazonInternalOs ( ) ? [ ...al2Config . args , nodePath , ...args ] : [ ...args ] ,
39+ { logging : 'no' }
40+ )
41+ }
3442/**
3543 * Checks that we can actually run the `node` executable and execute code with it.
3644 */
3745export async function validateNodeExe ( nodePath : string , lsp : string , args : string [ ] , logger : Logger ) {
3846 // Check that we can start `node` by itself.
39- const proc = new ChildProcess (
40- isAmazonInternalOs ( ) ? al2Config . path : nodePath ,
41- isAmazonInternalOs ( )
42- ? [ ...al2Config . args , nodePath , '-e' , 'console.log("ok " + process.version)' ]
43- : [ '-e' , 'console.log("ok " + process.version)' ] ,
44- { logging : 'no' }
45- )
47+ const proc = createNodeProcess ( nodePath , [ '-e' , 'console.log("ok")' ] )
4648 const r = await proc . run ( )
4749 const ok = r . exitCode === 0 && r . stdout . includes ( 'ok' )
4850 if ( ! ok ) {
@@ -52,11 +54,7 @@ export async function validateNodeExe(nodePath: string, lsp: string, args: strin
5254 }
5355
5456 // Check that we can start `node …/lsp.js --stdio …`.
55- const lspProc = new ChildProcess (
56- isAmazonInternalOs ( ) ? al2Config . path : nodePath ,
57- isAmazonInternalOs ( ) ? [ ...al2Config . args , nodePath , lsp , ...args ] : [ lsp , ...args ] ,
58- { logging : 'no' }
59- )
57+ const lspProc = createNodeProcess ( nodePath , [ lsp , ...args ] )
6058
6159 try {
6260 // Start asynchronously (it never stops; we need to stop it below).
@@ -105,11 +103,7 @@ export function createServerOptions({
105103 if ( isDebugInstance ( ) ) {
106104 args . unshift ( '--inspect=6080' )
107105 }
108- const lspProcess = new ChildProcess (
109- isAmazonInternalOs ( ) ? al2Config . path : executable ,
110- isAmazonInternalOs ( ) ? [ ...al2Config . args , executable , ...args ] : args ,
111- { logging : 'no' }
112- )
106+ const lspProcess = createNodeProcess ( executable , args )
113107 // this is a long running process, awaiting it will never resolve
114108 void lspProcess . run ( )
115109
0 commit comments