Node app on heroku fails due to read only filesystem - node.js

I have a very simple TypeScript app (build with Express.js) that runs on Node which I deploy to Heroku. I use both the node buildpack and zidizei/heroku-buildpack-tsc, the latter of which compiles the .ts to JavaScript at deploy time.
This has worked fine up to today when I tried to run a deploy. The deployment itself works fine but the app crashes subsequently at the point at which the launch script node ./dist/server.js is run. Logs here:
Sep 06 14:43:33 goodlord-bark app/web.1: $ node ./dist/server.js
Sep 06 14:43:33 goodlord-bark heroku/web.1: Process exited with status 1
Sep 06 14:43:33 goodlord-bark heroku/web.1: State changed from starting to crashed
Sep 06 14:43:33 goodlord-bark app/web.1: error An unexpected error occurred: "EROFS: read-only file system, access '/usr/local/bin'".
Sep 06 14:43:33 goodlord-bark app/web.1: info If you think this is a bug, please open a bug report with the information provided in "/app/yarn-error.log".
At no point does any script or my app attempt to write to /usr/local/bin so I'm confused as to why this is happening. This error only occurred following a superficial change to the codebase and new deploy so it strikes me something has changed on Heroku's end but I can get to the bottom of it.
Rolling back to a previous deploy has kept my app running for the time being, but I'm currently unable to deploy any updates.
There is also no /app/yarn-error.log to examine.

I just had similar issue on Heroku all of a sudden. Turns out the issue was introduced at yarn 1.0.0 and Heroku use the latest version by default. Here's a relevant heroku-buildpack-nodejs issue.
Fixed by downgrading yarn in engines section of package.json:
"engines": {
"node": "^7.10.1",
"yarn": "0.27.5"
}

Related

OPC Publisher module does not start on my Ubuntu VM as an edge module

The OPC Publisher marketplace image runs successfully as a standalone container (albeit with server connection problems). But I am not able to deploy it as an edge module, especially after changing container create options.
Background: In my host laptop I was never able to get the module up so I created a Ubuntu VM. When I tried to deploy the edge module in the VM with default container create options the module did show up in the iotedge module list as "running". I wanted to set the "--op" option to set publishing rate so I changed it in the create options using the portal "Set modules" tab. Since there is no update button I used create button to "recreate" the modules. After this the module did not show up.
After that the OPC publisher module is not showing up on the edge VM. I am following the Microsoft tutorial.
Following is the command:
sudo docker run -v /iiotedge:/appdata mcr.microsoft.com/iotedge/opc-publisher:latest --aa --pf=/appdata/publishednodes.json --c="HostName=<iot hub name>.azure-devices.net;DeviceId=iothubowner;SharedAccessKey=<hub primary key>" --dc="HostName=<edge device id/name>.azure-devices.net;DeviceId=<edge device id/name>;SharedAccessKey=<edge primary key>" --op=10000
Container create options:
{
"Hostname": "opcpublisher",
"Cmd": [
"--pf=/appdata/publishednodes.json",
"--aa",
"--op=10000"
],
"HostConfig": {
"Binds": [
"/iiotedge:/appdata"
]
}
}
I have not specified the connection strings explicitly since the documentation from Microsoft assures that the runtime will pass them automatically.
The relevant iotedge journalctl logs are here.
Oct 06 19:36:05 shreesha-VirtualBox iotedged[9622]: 2021-10-06T14:06:05Z [INFO] - Pulling image mcr.microsoft.com/iotedge/opc-publisher:latest...
Oct 06 19:36:08 shreesha-VirtualBox iotedged[9622]: 2021-10-06T14:06:08Z [INFO] - Successfully pulled image mcr.microsoft.com/iotedge/opc-publisher:latest
Oct 06 19:36:08 shreesha-VirtualBox iotedged[9622]: 2021-10-06T14:06:08Z [INFO] - Creating module OPCPublisher...
Oct 06 19:36:08 shreesha-VirtualBox iotedged[9622]: 2021-10-06T14:06:08Z [INFO] - Starting new listener for module OPCPublisher
Oct 06 19:36:08 shreesha-VirtualBox iotedged[9622]: 2021-10-06T14:06:08Z [ERR!] - Internal server error: Could not create module OPCPublisher
Oct 06 19:36:08 shreesha-VirtualBox iotedged[9622]: caused by: Could not get module OPCPublisher
The logs from iotedge itself is not much useful. Find below anyway.
~$ iotedge logs OPCPublisher
A module runtime error occurred
I have also tried docker container prune just to be sure but it did not help.
Also strangely in the Azure portal when I try to restart the module from the troubleshoot page it throws an error "module not found in the current environment"
Can someone please help me out in troubleshooting this problem? I will be glad to share more details if required.
I raised a support query in Azure portal. After sending support bundles and trying various suggestions like removing DNS configuration, changing bind path to a non-sudo location etc. the team zeroed in on the edge version mismatch.
After re-reading the documentation I uninstalled the earlier iotedge package and installed aziot-edge instead and problem solved!
The team has raised a github issue for public tracking here:
https://github.com/Azure/Industrial-IoT/issues/1425
#asergaz also pointed to the right direction but did not notice since it came a bit later

Getting NPM error: "Resolving deps of app\app.ts failed."

I'm trying to install and utilize this brunch.io skeleton. I keep running into this error:
20 Apr 19:40:21 - info: application started on http://localhost:3333/
20 Apr 19:40:24 - info: compiling
20 Apr 19:40:28 - error: Resolving deps of app\app.ts failed. Could not load module 'app\home' from 'C:\Users\tyler.WORKGROUP\Documents\GitHub\zenith-folio\app'. Possible solution: add 'app' to package.json and `npm install`.
20 Apr 19:40:28 - error: Resolving deps of app\about\index.ts failed. Could not load module 'app\about\about.tpl' from 'C:\Users\tyler.WORKGROUP\Documents\GitHub\zenith-folio\app\about'. Possible solution: add 'app' to package.json and `npm install`.
20 Apr 19:40:28 - info: compiling.
20 Apr 19:40:29 - info: compiled 477 files into 2 files, copied index.html in 8.4 sec
I'm trying my best to understand what's going on here, but I'm not sure. I can see that I need to add "app" to package.json, but I don't know how or which "app" it's specifying. Is it talking about:
the folder called "app"
a file called app.ts
Or is there something else I'm missing?
Message is pretty clear: Could not load module 'app\home', it means that you have unresolved import in app.ts which possibly looks like import ... from 'app\home';

hubot-slack throwing an error on startup

I am trying to add a new hubot integration to our Slack channels. I am setting this up on a Windows machine and am deploying to a Heroku server. I followed the installation instructions provided here: https://github.com/slackhq/hubot-slack
I can create and run a new hubot instance on my local computer (calling "bin/hubot" in a Powershell prompt), but when I install the hubot-slack package and add "hubot-slack" to the external-scripts file I get an error. If I remove the value from the external-scripts file everything is fine.
PS C:\hubot> bin/hubot
jarvis> [Tue Dec 22 2015 15:18:24 GMT-0800 (Pacific Standard Time)] ERROR Error loading scripts from npm package - TypeError: require(...) is not a function
at Robot.loadExternalScripts (C:\hubot\node_modules\hubot\src\robot.coffee:399:11)
at C:\hubot\node_modules\hubot\bin\hubot:128:26
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
If I include the adapter flag for Slack I get a different error. I tried setting HUBOT_SLACK_TOKEN as a System Environment variable.
PS C:\hubot> bin/hubot -a slack
[Tue Dec 22 2015 15:21:54 GMT-0800 (Pacific Standard Time)] ERROR No services token provided to Hubot
Every example I can find is including the HUBOT_SLACK_TOKEN in the call to hubot, but it doesn't work for me (I must be missing something).
PS C:\hubot> HUBOT_SLACK_TOKEN=xoxb-22211110000-123456781234ZZZZYYYYXXXX ./bin/hubot --adapter slack
HUBOT_SLACK_TOKEN=xoxb-17240119159-dBeAEc2X8M2O9vJBYzWj5KFW : The term
'HUBOT_SLACK_TOKEN=xoxb-17240119159-dBeAEc2X8M2O9vJBYzWj5KFW' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ HUBOT_SLACK_TOKEN=xoxb-22211110000-123456781234ZZZZYYYYXXXX ./bin/hubot --adapte ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HUBOT_SLACK_TOK...234ZZZZYYYYXXXX:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
To rule out something locally I deployed the application to Heroku, but I got a different error.
2015-12-22T22:28:49.426496+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-22T22:14:54.739959+00:00 heroku[web.1]: State changed from starting to up
2015-12-22T22:14:55.133113+00:00 app[web.1]: [Tue Dec 22 2015 22:14:55 GMT+0000 (UTC)] ERROR Error loading scripts from npm package - TypeError: object is not a function
2015-12-22T22:14:55.133117+00:00 app[web.1]: at Robot.loadExternalScripts (/app/node_modules/hubot/src/robot.coffee:399:11, <js>:269:39)
2015-12-22T22:14:55.133119+00:00 app[web.1]: at fs.js:272:14
2015-12-22T22:14:55.133121+00:00 app[web.1]: at Object.oncomplete (fs.js:108:15)
2015-12-22T22:14:56.115333+00:00 heroku[web.1]: State changed from up to crashed
package.json:
{
"name": "jarvis",
"version": "0.0.0",
"private": true,
"author": "Me <email#domain.com>",
"description": "A friendly robot",
"dependencies": {
"hubot": "^2.17.0",
"hubot-diagnostics": "0.0.1",
"hubot-google-images": "^0.2.6",
"hubot-google-translate": "^0.2.0",
"hubot-help": "^0.1.2",
"hubot-heroku-keepalive": "^1.0.1",
"hubot-maps": "0.0.2",
"hubot-pugme": "^0.1.0",
"hubot-redis-brain": "0.0.3",
"hubot-rules": "^0.1.1",
"hubot-scripts": "^2.16.2",
"hubot-shipit": "^0.2.0",
"requirejs": "^2.1.22",
"hubot-slack": "^3.4.2"
},
"engines": {
"node": "0.10.x"
}
}
external-scripts.json
[
"hubot-diagnostics",
"hubot-help",
"hubot-heroku-keepalive",
"hubot-google-images",
"hubot-google-translate",
"hubot-pugme",
"hubot-maps",
"hubot-redis-brain",
"hubot-rules",
"hubot-shipit",
"requirejs",
"hubot-slack"
]
On Windows, it seems that the mechanism is a little different from what it processes in Linux. The error 'HUBOT_SLACK_TOKEN is not recognized' is raised because it would read the value of 'HUBOT_SLACK_TOKEN' from environment variables in windows.
Create an environment variable 'HUBOT_SLACK_TOKEN' manually and set the value, it will work.
You could check it out in the source code in the github repo: slack.coffee.
options =
token: process.env.HUBOT_SLACK_TOKEN
autoReconnect: !exitProcessOnDisconnect
autoMark: true
exitOnDisconnect: exitProcessOnDisconnect
proxyUrl: process.env.https_proxy
What intrigues me is this particular line:
Error loading scripts from npm package - TypeError: require(...) is not a function
Did you add the other scripts from the repo aswell?
There also might be something wrong with the node/npm/coffee installation/version on your windows machine. Make sure that those are installed and in a compatible version. Another thread had an issue with incompatible versions. Please tell us about the versions you use and try downgrading node to 0.12.x.
The way you use the token is fine.

Issue when deploying Yesod 1.4 to Heroku

im having a problem when deploying a new Yesod application to heroku. I am following the steps here;
https://github.com/yesodweb/yesod/wiki/Deploying-Yesod-Apps-to-Heroku
But since yesod 1.4 was released, I am getting the following issue show up in my logs (PaperTrail);
Dec 21 04:42:51 fxtest heroku/web.1: Starting process with command ./dist/build/fxtest/fxtest production -p 37347
Dec 21 04:42:52 fxtest app/web.1: loadAppSettings: Could not parse file as YAML: production
Dec 21 04:42:52 fxtest app/web.1: fxtest: InvalidYaml (Just (YamlException "Yaml file not found: production"))
Dec 21 04:42:53 fxtest heroku/web.1: Process exited with status 1
Dec 21 04:42:53 fxtest heroku/web.1: State changed from starting to crashed
This appears to say that I have a missing yaml file called "production". If I try to negate this error by adding a dummy yaml file, then I get a similar error telling me I am missing a file called "-p". This leads me to think that the issue is being caused by my Procfile, which only contains one line;
web: ./dist/build/fxtest/fxtest production -p $PORT
thanks in advance for any help
If you're using the new scaffolding, it no longer requires the command line parameter. Try dropping production from the command, and probably leave of the-p $PORT as well.

Nodeclipse + Nodemon dont want to start apps

i set in prefences in Node Path C:!NnS\NodeJS!LIBS\nodemon.cmd
nodemod.cmd
"%~dp0\node.exe" "%~dp0\node_modules\nodemon\nodemon.js" %*
error
21 Aug 17:12:11 - [33m[nodemon] v0.7.10[0m
21 Aug 17:12:11 - [33m[nodemon] to restart at any time, enter rs[0m
21 Aug 17:12:11 - [32m[nodemon] watching: C:\Users\Admin\Desktop\nodeclipse-NTS-jee-kepler-win64\ws\NodeProject-1[0m
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
21 Aug 17:12:11 - [32m[nodemon] starting node C:\Users\Admin\Desktop\nodeclipse-NTS-jee-kepler-win64\ws\NodeProject-1\hello-world-server.js[0m
21 Aug 17:12:11 - [nodemon] exception in nodemon killing node
if i will start "nodemod.cmd app.js" all works
ps.
nodemon plugins for whatch on filechanges and make restart on any changes
https://github.com/remy/nodemon
Running node application with node-dev, forever, supervisor, nodemon etc
as of Nodeclipse 0.4.0 is not yet supported, issue #57 https://github.com/Nodeclipse/nodeclipse-1/issues/57
It is really smart to try enter path to such utils into Node path Preferences settings,
but it is not how that setting is meant to be used.
UPDATE (The solution you have mentioned) run app with a wrapper:
Looks like if in main app will be something like this... all will be ok :)
spawn("nodemon.cmd", ["main.js"]...
and
spawn("nodemon",[" --debug ./server.js 80"]...
But I personally would prefer to open console with StartExplorer see Plugins List
(right-click project -> StartExplorer -> open shell)
then nodemon main

Resources