Browse Source

Catch stream errors. Maybe addresses #228

dev/git-series/gccdum
Matt Godbolt 6 years ago
parent
commit
0d04f0b437
  1. 16
      .idea/libraries/Cargo__rustfilt_.xml
  2. 53
      lib/base-compiler.js

16
.idea/libraries/Cargo__rustfilt_.xml

@ -1,19 +1,19 @@
<component name="libraryTable">
<library name="Cargo &lt;rustfilt&gt;">
<CLASSES>
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-demangle-0.1.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/utf8-ranges-0.1.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.18" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.2" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-id-2.0.0" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/kernel32-sys-0.2.2" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.2" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.18" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-0.2.7" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-build-0.1.1" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.1.80" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-0.1.11" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.3.9" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-0.2.7" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-0.1.11" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.2.8" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-demangle-0.1.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/utf8-ranges-0.1.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-build-0.1.1" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3" />
</CLASSES>
<JAVADOC />
<SOURCES />

53
lib/base-compiler.js

@ -276,36 +276,37 @@ Compile.prototype.exec = function (command, args, options) {
if (running) treeKill(child.pid);
}
var stderr = "";
var stdout = "";
var streams = {
stderr: "",
stdout: "",
truncated: false
};
var timeout;
if (timeoutMs) timeout = setTimeout(function () {
logger.warn("Timeout for", command, args, "after", timeoutMs, "ms");
okToCache = false;
kill();
stderr += "\nKilled - processing time exceeded";
streams.stderr += "\nKilled - processing time exceeded";
}, timeoutMs);
var truncated = false;
child.stdout.on('data', function (data) {
if (truncated) return;
if (stdout.length > maxOutput) {
stdout += "\n[Truncated]";
truncated = true;
kill();
return;
}
stdout += data;
});
child.stderr.on('data', function (data) {
if (truncated) return;
if (stderr.length > maxOutput) {
stderr += "\n[Truncated]";
truncated = true;
kill();
return;
}
stderr += data;
});
function setupStream(stream, name) {
stream.on('data', function (data) {
if (streams.truncated) return;
if (streams[name].length > maxOutput) {
streams[name] += "\n[Truncated]";
streams.truncated = true;
kill();
return;
}
streams[name] += data;
});
stream.on('error', function (err) {
logger.error('Error with stream:', err);
});
}
setupStream(child.stdout, 'stdout');
setupStream(child.stderr, 'stderr');
child.on('exit', function (code) {
logger.debug({type: 'exited', code: code});
if (timeout !== undefined) clearTimeout(timeout);
@ -320,8 +321,8 @@ Compile.prototype.exec = function (command, args, options) {
if (timeout !== undefined) clearTimeout(timeout);
var result = {
code: code,
stdout: stdout,
stderr: stderr,
stdout: streams.stdout,
stderr: streams.stderr,
okToCache: okToCache
};
logger.debug({type: "executed", command: command, args: args, result: result});

Loading…
Cancel
Save