diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e23d4cb..eba5a82b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! This project adheres to [Semantic Versioning](http://semver.org/). +## v6.3.10 - 2017-10-31 + +* Use a custom webpack loader to avoid uncaught exceptions from JSONStream #517 [Pablo Carranza Velez] + ## v6.3.9 - 2017-10-30 * Avoid fetching an image when it might be available or when starting an app because it might not be necessary #507 [Pablo Carranza Velez] diff --git a/Dockerfile b/Dockerfile index be877208..2f4bb84a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -143,7 +143,7 @@ COPY package.json /usr/src/app/ RUN JOBS=MAX npm install --production --no-optional --unsafe-perm \ && npm dedupe -COPY webpack.config.js remove-hashbang-loader.js /usr/src/app/ +COPY webpack.config.js fix-jsonstream.js /usr/src/app/ COPY src /usr/src/app/src # Install devDependencies, build the coffeescript and then prune the deps diff --git a/fix-jsonstream.js b/fix-jsonstream.js new file mode 100644 index 00000000..9db46d79 --- /dev/null +++ b/fix-jsonstream.js @@ -0,0 +1,9 @@ +// JSONStream is a hybrid executable-library +// and has a #! /usr/bin/env node at the beginning of the file. +// This webpack loader removes it so that we have valid javascript for webpack to load. +// Also, JSONStream starts a pipe between stdin and stdout if module.parent is undefined. +// This pipe can fail throwing an uncaught exception, so we fake a module.parent to prevent this. +// See https://github.com/dominictarr/JSONStream/issues/129 +module.exports = function (source) { + return "module.parent = {};\n" + source.toString().replace(/^#! .*\n/, '') +} diff --git a/package.json b/package.json index c3de2db9..a4955daa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "resin-supervisor", "description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.", - "version": "6.3.9", + "version": "6.3.10", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/remove-hashbang-loader.js b/remove-hashbang-loader.js deleted file mode 100644 index 53f25bdd..00000000 --- a/remove-hashbang-loader.js +++ /dev/null @@ -1,6 +0,0 @@ -// Some of the dependencies (e.g. JSONStream) are hybrid executable-library -// and have a #! /usr/bin/env node at the beginning of the file. -// This webpack loader removes it so that we have valid javascript for webpack to load. -module.exports = function (source) { - return source.toString().replace(/^#! .*\n/, '') -} diff --git a/webpack.config.js b/webpack.config.js index 24c57b99..d2347d03 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -62,8 +62,8 @@ module.exports = { module: { rules: [ { - test: /\.js$/, - use: require.resolve('./remove-hashbang-loader') + test: /JSONStream\/index\.js$/, + use: require.resolve('./fix-jsonstream') }, { test: /\.coffee$/,