Blockchain (Avalanche) faucet implementation in the local test network - node.js

I am trying to implement a faucet for my local testnet which consists of 5 node. To do that I followed the avalances github documentation as in the link,
https://github.com/ava-labs/avalanche-faucet
In short, basically, I run my 5 nodes and all nodes runs successfully using an Ubuntu Sandbox. Also, the bootstrap is finished. Then tried to run the below command in the Ubuntu,
Platform Versions: Ubuntu 20.04.2 LTS
node-js v16.2.0
npm 7.15.0
Yarn 1.22.5
Creating Faucet:
Clone the repository git clone https://github.com/ava-labs/avalanche-faucet.git
Go to the root directory cd avalanche-faucet
Install javascript dependencies with yarn install.
Create a .env file by copying .env.example
Install AvalancheGo, our Avalanche node client written in Golang to spin up a network (https://github.com/ava-labs/avalanchego).
Running Project:
Make sure you have installed and able to run an Avalanche node properly.
All environment variables are correct and your private key has funds in it.
Run the project with hot reloading yarn serve
Everything is goes ok but when I run yarn serve then the below Error pop up. "Assertion `thread_id_key != 0x7777' failed."
43% building 275/282 modules 7 active ...cet/node_modules/babel-loader/lib/index.js!/home/avalanchelocal1/Downloads/avalanche-faucet/node_modules/vuetify/lib/services/index.jsnode: ../src/coroutine.cc:134: void* find_thread_id_key(void*): Assertion `thread_id_key != 0x7777' failed.
Aborted (core dumped)
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Related

Stop EBS Linux 2 (Node.js) from trying to do npm install?

I'm trying to run a Node application on AWS Linux 2 on Elastic Beanstalk and need to install the dependencies using yarn. (My Node app causes errors if you try to use npm to install dependencies instead of yarn.)
I've already figured out how to set up a script in .platform/hooks/prebuild/ to get it to run yarn, but even though it's running the yarn installation, it still also tries to run npm install, which errors out, causing my deploy to fail.
So I need to figure out how to prevent the default npm install step from running.
(Does anyone know what file that command is run from in the AWS Linux 2 setup process? I was wondering if I could just add another script in .platform/hooks/prebuild/ that would modify that file to prevent the call to npm.)
yes, you can avoid npm install
When you deploy a node_modules directory to an Amazon Linux 2 Node.js platform version, Elastic Beanstalk assumes that you're providing your own dependency packages, and avoids installing dependencies specified in a package.json file.
source doc

React app build fails in Docker in Jenkins, but not locally

On my local machine, npm run build works just fine. On my Docker image launched via Jenkins, I get issues like
Cannot find module: 'file-saver'. Make sure this package is installed.
You can install this package by running: npm install file-saver.
and
FAIL src/core/App.test.js
● Test suite failed to run
Cannot find module 'surface-nets' from 'vtext.js'
On my local machine, I have cleared the npm cache (npm cache clean -f), removed node_modules/, and reinstalled (npm i). I have even used npm update and the npm-check-updates package to update everything. I installed all peer dependencies. My local copy should be as wiped-clean as the copy within Docker is. In the Jenkinsfile, I put npm list and it shows surface-nets and file-saver and all my other packages. I also put ls node_modules/ and I can see the package folders are there. I have reduced my Dockerfile down to just 1 line: FROM node:current.
Why is it saying "Cannot find module" when the modules are installed?
The root cause of this issue is still unknown, but I did find out that the repository was corrupted. I ended up wiping the whole remote repo and git init-ing a new one, then pushing to that. I assume that corruption contributed to the issue at hand here.

Continuous integration: Where to build the project?

I have a Jenkins server on which I observe a private git repository for changes, which then triggers a pipeline script (the repository contains a nodejs app). In this pipeline script I need to do the following steps:
Install dependencies (npm install)
Build my application (npm run build, which creates a dist folder)
Build a docker container (docker build) and run the container (which runs a script in the dist folder)
Which of the following two options would be the recommended way to do this, and why?
Option A: Run npm install and npm run build in the jenkins pipeline and copy the dist folder to the docker container during the docker build. This would allow me to only install runtime dependencies in the docker container using npm install --only=production, therefore reducing the image size significantly.
Option B: Run npm install and npm run build during docker build (In the Dockerfile). This would allow me to run the docker container outside the CI server if I have to (I don't have a use case for it now, but it seems cleaner because it is more independent). However, the image size would significantly increase and I am not sure if this is the recommended way.
Any suggestions?
I would choose option B.
The reason behind it would be that there are some npm packages that runs a node-gyp, gcc, and other platform-dependent builds.
Look at the popular bcrypt package as an example.
Going with option A would mean that your docker and Jenkins machine need to hold the same infra for such builds which is not common, to say the least.

yarn install consumes all memory on TeamCity and Jenkins

I'd really like to get yarn working with TeamCity or Jenkins, however
yarn install consumes all my build server's cpu & memory, even with
a tiny npm project. Any idea why?
Summary
yarn install, when run by TeamCity or Jenkins, consumes most CPU/memory, never finishes
running yarn install from the command line on the build server works (finishes in a few seconds)
npm install completes in a few seconds when run by TeamCity/Jenkins
build server: Windows Server 2012, 2 cores, 4GB mem
yarn version 1.6.0
Jenkins version 2.107.2
TeamCity version 2017.2.3
Have tried Node.js versions 8.11.1 and 9.11.1
Details
Steps:
Create a tiny npm project:
mkdir temp
cd temp
yarn init # all defaults
yarn add dummy-module # tiny test package
Commit this to git, set up a Jenkins or TeamCity build with a single command yarn install.
The build never finishes, with the last line of console output: yarn install v1.6.0.
At this time, the Node.js process is consuming most of the CPU and memory on the
build machine. Changing the command to npm install makes it run successfully.
Since it's common to Jenkins and TeamCity, it seems like the problem is to do with
running sub processes from java. I can't find any indication of what's going wrong
in either the TeamCity or Jenkins logs. When aborting the Jenkins build,
I see the following in jenkins.err.log:
Apr 22, 2018 8:59:11 AM hudson.model.Run execute
INFO: master-cake #9 aborted
java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(Unknown Source)
at hudson.Proc$LocalProc.join(Proc.java:324)
at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:155)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1727)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
I left some crucial information out of the original question - I'm also using yarn's offline mirror, which was stored on a network drive. It turns out that the TeamCity windows service can't access network drives: https://confluence.jetbrains.com/display/TCD10/Known+Issues#KnownIssues-AgentrunningasWindowsServiceLimitations
Relocating yarn's offline mirror to a local directory solved the issue for both TeamCity and Jenkins.

jenkins continues deploy process, although NPM fails installing modules

I've got a deploy process set up in jenkins, which first installs the entire JavaScript app locally on the jenkins server, starts grunt for testing/building the app, and copies everything over to a staging machine afterwards.
Yesterday I noticed that I had a typo in my package.json and npm failed to install an updated module, thus throwing a warning.
Jenkins seems to have noticed that issue and marked the build as UNSTABLE, but kept on deploying (Post-Build tasks using ssh-copy plugin).
Is there a way to stop a build process when NPM fails to install a module?
you can try
npm install || exit 1
What this command says is if the "npm install" command didn't run successfully (didn't return exit code of 0) then "exit 1"
For reference:
How to exit if a command failed?

Resources