isomorfeus-speednode 0.4.0 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isomorfeus/speednode/runner.js +16 -13
- data/lib/isomorfeus/speednode/runtime/vm.rb +14 -9
- data/lib/isomorfeus/speednode/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a2f7d96883b92de64ef9d3432854caba940a961a38bc4c22067c33eb8e6c9cd
|
4
|
+
data.tar.gz: 82bdc61da0e3aa48348e59d600e6d39658b7e6fd04f17f00b89cbf0db4986e38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6944313b70b37a8fcea6598d4b83e437b644e86ce63a5989b7ce6d55d8f8786eafa33a629bfafbd2c5ee9be167967128e03ab82cb93f873f6f0bd70877bd9fd3
|
7
|
+
data.tar.gz: e06a2a69e670619b5660c9da30d14d7b4f6a8a34d1688ebac88c597bc411c2ef78d8f949496829602f329afd58c7a3c1ccd4e7a3a306be5567b9dbd45e7668c2
|
@@ -135,7 +135,7 @@ function attachFunctionSource(responder_path, context, func) {
|
|
135
135
|
if (!global.__responder_socket) {\n\
|
136
136
|
return new Promise(function(resolve, reject) {\n\
|
137
137
|
setTimeout(function(){\n\
|
138
|
-
if (os.platform().indexOf('win')
|
138
|
+
if (os.platform().indexOf('win') == 0) {\n\
|
139
139
|
let socket = net.connect(responder_path);\n\
|
140
140
|
socket.on('connect', function(){\n\
|
141
141
|
global.__responder_socket = true;\n\
|
@@ -160,9 +160,9 @@ function attachFunctionSource(responder_path, context, func) {
|
|
160
160
|
socket.on('error', function (err) {\n\
|
161
161
|
if (err.syscall === 'connect') {\n\
|
162
162
|
// ignore, close will handle\n\
|
163
|
-
} else if (os.platform().indexOf('win')
|
163
|
+
} else if ((os.platform().indexOf('win') == 0) && err.message.includes('read EPIPE')) {\n\
|
164
164
|
// ignore, close will handle\n\
|
165
|
-
} else if (os.platform().indexOf('win')
|
165
|
+
} else if ((os.platform().indexOf('win') == 0) && err.message.includes('write EPIPE')) {\n\
|
166
166
|
// ignore, close will handle\n\
|
167
167
|
} else { reject(err); }\n\
|
168
168
|
});\n\
|
@@ -200,7 +200,8 @@ function createCompatibleContext(uuid, options) {
|
|
200
200
|
}
|
201
201
|
|
202
202
|
function createPermissiveContext(uuid, options) {
|
203
|
-
let c = vm.createContext({
|
203
|
+
let c = vm.createContext({ __responder_socket: false, process: { release: { name: "node" }, env: process.env }, Buffer, clearTimeout, fs, net, os, require, setTimeout });
|
204
|
+
vm.runInContext('global = globalThis;', c);
|
204
205
|
contexts[uuid] = { context: c, options: options };
|
205
206
|
return c;
|
206
207
|
}
|
@@ -223,7 +224,7 @@ function getContextOptions(uuid) {
|
|
223
224
|
if (contexts[uuid].options.timeout) {
|
224
225
|
options.timeout = contexts[uuid].options.timeout;
|
225
226
|
}
|
226
|
-
return options;
|
227
|
+
return options;
|
227
228
|
}
|
228
229
|
|
229
230
|
function massageStackTrace(stack) {
|
@@ -241,7 +242,7 @@ let commands = {
|
|
241
242
|
attach: function(input) {
|
242
243
|
let context = getContext(input.context);
|
243
244
|
let responder_path;
|
244
|
-
if (os.platform().indexOf('win')
|
245
|
+
if (os.platform().indexOf('win') == 0) { responder_path = '\\\\\\\\.\\\\pipe\\\\' + socket_path + '_responder'; }
|
245
246
|
else { responder_path = socket_path + '_responder' }
|
246
247
|
let result = vm.runInContext(attachFunctionSource(responder_path, input.context, input.func), context, { filename: "(execjs)", displayErrors: true });
|
247
248
|
return formatResult(result);
|
@@ -285,23 +286,23 @@ let server = net.createServer(function(s) {
|
|
285
286
|
s.on('data', function (data) {
|
286
287
|
received_data.push(data);
|
287
288
|
if (data[data.length - 1] !== 4) { return; }
|
288
|
-
|
289
|
+
|
289
290
|
let request = received_data.join('').toString('utf8');
|
290
291
|
request = request.substr(0, request.length - 1);
|
291
292
|
received_data = [];
|
292
|
-
|
293
|
+
|
293
294
|
let input, result;
|
294
295
|
let outputJSON = '';
|
295
296
|
|
296
297
|
try { input = JSON.parse(request); }
|
297
|
-
catch(err) {
|
298
|
+
catch(err) {
|
298
299
|
outputJSON = JSON.stringify(['err', ['', err].join(''), err.stack]);
|
299
300
|
s.write([outputJSON, "\x04"].join(''));
|
300
301
|
return;
|
301
302
|
}
|
302
303
|
|
303
|
-
try { result = commands[input.cmd].apply(null, input.args); }
|
304
|
-
catch (err) {
|
304
|
+
try { result = commands[input.cmd].apply(null, input.args); }
|
305
|
+
catch (err) {
|
305
306
|
outputJSON = JSON.stringify(['err', ['', err].join(''), massageStackTrace(err.stack)]);
|
306
307
|
s.write([outputJSON, "\x04"].join(''));
|
307
308
|
return;
|
@@ -312,13 +313,15 @@ let server = net.createServer(function(s) {
|
|
312
313
|
if (err.message.includes('circular')) { outputJSON = CircularJSON.stringify(result); }
|
313
314
|
else { outputJSON = JSON.stringify([['', err].join(''), err.stack]); }
|
314
315
|
s.write([outputJSON, "\x04"].join(''));
|
316
|
+
if (process_exit !== false) { process.exit(process_exit); }
|
315
317
|
return;
|
316
318
|
}
|
317
319
|
|
318
|
-
s.write([outputJSON, "\x04"].join(''));
|
320
|
+
try { s.write([outputJSON, "\x04"].join('')); }
|
321
|
+
catch (err) {}
|
319
322
|
if (process_exit !== false) { process.exit(process_exit); }
|
320
323
|
});
|
321
324
|
});
|
322
325
|
|
323
|
-
if (os.platform().indexOf('win')
|
326
|
+
if (os.platform().indexOf('win') == 0) { server.listen('\\\\.\\pipe\\' + socket_path); }
|
324
327
|
else { server.listen(socket_path); }
|
@@ -56,8 +56,8 @@ module Isomorfeus
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.finalize(socket, socket_dir, socket_path, pid)
|
59
|
-
proc do
|
60
|
-
Isomorfeus::Speednode::Runtime.responders
|
59
|
+
proc do
|
60
|
+
Isomorfeus::Speednode::Runtime.responders[socket_path].kill if Isomorfeus::Speednode::Runtime.responders[socket_path]
|
61
61
|
exit_node(socket, socket_dir, socket_path, pid)
|
62
62
|
end
|
63
63
|
end
|
@@ -65,14 +65,18 @@ module Isomorfeus
|
|
65
65
|
def self.exit_node(socket, socket_dir, socket_path, pid)
|
66
66
|
VMCommand.new(socket, "exit", [0]).execute
|
67
67
|
socket.close
|
68
|
-
File.unlink(socket_path)
|
69
|
-
Dir.rmdir(socket_dir)
|
68
|
+
File.unlink(socket_path) if File.exist?(socket_path)
|
69
|
+
Dir.rmdir(socket_dir) if socket_dir && Dir.exist?(socket_dir)
|
70
70
|
if Gem.win_platform?
|
71
71
|
# SIGINT or SIGKILL are unreliable on Windows, try native taskkill first
|
72
|
-
|
72
|
+
unless system("taskkill /f /t /pid #{pid} >NUL 2>NUL")
|
73
|
+
Process.kill('KILL', pid) rescue nil
|
74
|
+
end
|
73
75
|
else
|
74
|
-
Process.kill
|
76
|
+
Process.kill('KILL', pid) rescue nil
|
75
77
|
end
|
78
|
+
rescue
|
79
|
+
nil
|
76
80
|
end
|
77
81
|
|
78
82
|
def eval(context, source)
|
@@ -93,7 +97,7 @@ module Isomorfeus
|
|
93
97
|
|
94
98
|
def attach(context, func)
|
95
99
|
create_responder(context) unless responder
|
96
|
-
command("attach", {'context' => context, 'func' => func })
|
100
|
+
command("attach", {'context' => context, 'func' => func })
|
97
101
|
end
|
98
102
|
|
99
103
|
def delete_context(context)
|
@@ -123,12 +127,12 @@ module Isomorfeus
|
|
123
127
|
end
|
124
128
|
@pid = Process.spawn({"SOCKET_PATH" => @socket_path}, @options[:binary], @options[:source_maps], @options[:runner_path])
|
125
129
|
|
126
|
-
retries =
|
130
|
+
retries = 100
|
127
131
|
|
128
132
|
if ExecJS.windows?
|
129
133
|
timeout_or_connected = false
|
130
134
|
begin
|
131
|
-
retries -= 1
|
135
|
+
retries -= 1
|
132
136
|
begin
|
133
137
|
@socket = Win32::Pipe::Client.new(@socket_path, Win32::Pipe::ACCESS_DUPLEX)
|
134
138
|
rescue
|
@@ -159,6 +163,7 @@ module Isomorfeus
|
|
159
163
|
end
|
160
164
|
|
161
165
|
ObjectSpace.define_finalizer(self, self.class.finalize(@socket, @socket_dir, @socket_path, @pid))
|
166
|
+
Kernel.at_exit { self.class.finalize(@socket, @socket_dir, @socket_path, @pid).call }
|
162
167
|
end
|
163
168
|
|
164
169
|
def create_responder(context)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-speednode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -28,28 +28,28 @@ dependencies:
|
|
28
28
|
name: oj
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.13.
|
33
|
+
version: 3.13.9
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.13.
|
40
|
+
version: 3.13.9
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: win32-pipe
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.2.
|
153
|
+
rubygems_version: 3.2.22
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: A fast ExecJS runtime based on nodejs, tuned for Isomorfeus.
|