how event loop phases handles the requests? - node.js

Event loop has phases as:
┌───────────────────────┐
┌─>│ timers │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
│ │ I/O callbacks │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
│ │ idle, prepare │
│ └──────────┬────────────┘ ┌───────────────┐
│ ┌──────────┴────────────┐ │ incoming: │
│ │ poll │<─────┤ connections, │
│ └──────────┬────────────┘ │ data, etc. │
│ ┌──────────┴────────────┐ └───────────────┘
│ │ check │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
└──┤ close callbacks │
└───────────────────────┘
how does it work? does it jump from one phase to another? if yes then when it jumps? or it just maintains the que and executes the one callback after the another? and what is next tick , does it mean that when entire que is completed and que is empty then the loop starts over again? is there any actual loop in event loop? and how does this poll phase works? what happens when a new request arrives?
node maintains the worker pool (which are actually c++ threads), and whenever a some I/O task or any other blocking task comes, it hands over that task to that worker thread which actually carries out system task as interacting with database and getting data and when worker thread completes its task than worker thread puts the callback handler in event que back, and node takes this callback and executes it . Is this correct?
what is nodejs binding(c++)?
how event loop works? does it run on main thread?

Related

SyntaxError: Unexpected identifier 'pipefail'

I am having this issue when I try to deploy NodeJS app (built with NextJS) using pm2. I follow the instruction described here.
My attempt to execute pm2 start command seemed working, as shown by the snippet below.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐ │ id │ name │ mode │ ↺ │ status │ cpu │ memory │ ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤ │ 0 │ experti │ fork │ 0 │ online │ 0% │ 25.7mb │ └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
But when I run pm2 list, the previous execution turned out to be error.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐ │ id │ name │ mode │ ↺ │ status │ cpu │ memory │ ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤ │ 0 │ process │ fork │ 15 │ errored │ 0% │ 0b │ └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
I checked the pm2 logs as described by this answer and it led me to this log:
`
SyntaxError: Unexpected identifier 'pipefail'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Object.<anonymous> (/home/equitica/.npm/_npx/5f7878ce38f1eb13/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
/home/<username>/.asdf/plugins/nodejs/shims/npm:4
set -o pipefail
^^^^^^^^
`
So, I checked the file that specified by the log, and found this line (shown below):
#! /usr/bin/env bash
set -eu
set -o pipefail <-- this line is probably the problem
I have no idea what the line means, and have no clue to solve the problem.
I solved this issue by removing the /home/<username>/.asdf/plugins/nodejs/shims/npm file and then execute pm2 start npm --name <process> -- run start.

When running terraform init, the following error is displayed

When running terraform init, the following error is displayed:
Could not retrieve the list of available versions for provider
│ hashicorp/azurerm: could not connect to registry.terraform.io: Failed to
│ request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http:
│ request canceled while waiting for connection (Client.Timeout exceeded
│ while awaiting headers)
What could be the reason?

Calculate Gain Loss Excel Percentage [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I've tried many ways of getting the percentage but it will not work for Gain/Loss
╭──────────────╥────────┬────────╥────────╮
│ ║ Jan │ Feb │ Mar │
╞══════════════╬════════╪════════╪════════╡
│ Amount ║ 100 │ 1000 │ 100 │
├──────────────╫────────┼────────┼────────┤
│ Change % ║ 0 │ -88% │ 733% │ C2/B2-1
╞══════════════╬════════╪════════╪════════╡
│ Amount ║ 300000 │ 9000 │ 300000 │
├──────────────╫────────┼────────┼────────┤
│ Change % ║ 0 │ -97% │ 3233% │ C4/B4-1
╰──────────────╨────────┴────────┴────────╯
How can I get the correct result with Gain/Loss? as -97% can't be if the opposite is 3233%
I reversed it, I made it into an if function, if anyone else is wanting to know how to get a steady Plus/Minus from Gains and Losses this formula worked for me
=IF(C4<=B4,1-B4/C4,C4/B4-1)

Why can't I add packages to flutter

I tried to add dependencies:
english_words: ^3.1.5 To my pupsec.yaml file, when I do and try the Flutter Pub Get command I get this error: Mathiass-MacBook-Pro:startuplabs_0 mathiassoderlund$ flutter pub get
Error on line 34, column 5 of pubspec.yaml: A dependency may only have one source.
╷
34 │ ┌ sdk: flutter
35 │ │
36 │ │ dependencies:
37 │ │ flutter:
38 │ │ sdk: flutter
39 │ │
40 │ │
41 │ │ english_words: ^3.1.5
42 │ │
43 │ │ # For information on the generic Dart part of this file, see the
44 │ │ # following page: https://dart.dev/tools/pub/pubspec
45 │ │
46 │ └ # The following section is specific to Flutter.
╵
Running "flutter pub get" in startuplabs_0...
pub get failed (65; ╵)
Mathiass-MacBook-Pro:startuplabs_0 mathiassoderlund$
Here is my pupspec.yaml file: Pupspec.yaml
You write it on the wrong place, Write it below cupertino_icons
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.5
Use proper indentation(spaces) in front of english_words.
The code should looks like this-
dependencies:
flutter:
sdk: flutter
english_words: ^3.1.5
Hope this will help you.

Parsoid Server didn't parse pages

Hello:) Got some problems with install of VisualEditor. I have to install Parsoid server and run it. But when I trying to parse some page, I'm getting an error:
TypeError: Cannot read property 'length' of undefined
at peg$c379 (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:1356:61)
at peg$parseeof (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:14738:12)
at peg$parsetlb (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:2007:12)
at peg$parsetoplevelblock (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:1909:12)
at Object.parse (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:17872:18)
at PegTokenizer.tokenizeAsync (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:206:24)
at PegTokenizer._processText (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:180:8)
at PegTokenizer.process (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:119:7)
at ParserPipeline.process (/opt/bitnami/apps/parsoid/lib/mediawiki.parser.js:485:21)
at Object.Util.processContentInPipeline (/opt/bitnami/apps/parsoid/lib/mediawiki.Util.js:1112:12)
This is not the same error like this, coz my express and connect versions look fine:
├── alea#0.0.9
├── async#0.9.0
├─┬ bunyan#1.0.1
│ └─┬ mv#2.0.3
│ ├─┬ mkdirp#0.5.0
│ │ └── minimist#0.0.8
│ ├── ncp#0.6.0
│ └── rimraf#2.2.8
├─┬ chai#1.9.2
│ ├── assertion-error#1.0.0
│ └─┬ deep-eql#0.1.3
│ └── type-detect#0.1.1
├── colors#0.6.2
├── diff#1.0.8
├── domino#1.0.18
├── entities#1.1.1
├── es6-shim#0.16.0
├─┬ express#2.5.11
│ ├─┬ connect#1.9.2
│ │ └── formidable#1.0.15
│ ├── mime#1.2.4
│ ├── mkdirp#0.3.0
│ └── qs#0.4.2
.......
I`ve got: NodeJS(v0.10.33), npm(2.1.5) on Ubuntu 14.04.1 LTS
Any ideas?:)
UPDATE:
I just noticed, that I can add new pages with VisualEditor and edit em, also i can edit already existing pages, but if there are no templates. If these pages have templates then there is an error previously described.
There was a problem with version (I got MW 1.23.6 (latest stable)).
I have to update to MediaWiki 1.24 and reinstall VisualEditor (Parsoid already exists in MW >1.24) and then it works fine without errors. Upstart on Ubuntu working well too.

Resources