Skip to content

Instantly share code, notes, and snippets.

View ankur-anand's full-sized avatar
💭
Seize The Day!

Ankur Anand ankur-anand

💭
Seize The Day!
View GitHub Profile

Post Mortem Debugging in NodeJS in the Light of Promises

Context:

we're discussing how we can safely abort on unhandled rejections and obtain meaningful debugging information. Related reading: https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#file-post-mortem-debugging-with-promises-md.

In particular, we're discussing https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#removing-implicit-trycatch-blocks-from-v8s-promises-implementation

Othe recommended reading: On unhandledRejection https://gist.github.com/benjamingr/0237932cee84712951a2

Part 1: Why bubbling is good

We start with the following code

function startListening(server, cb) {
  server.listen(99999, 'localhost', cb)
}
@ankur-anand
ankur-anand / eslint_notes.md
Created January 22, 2018 06:53
ESLINT PRETTIER Notes

"ESLINT PRETTIER" === "CODE QUALITY"

PRETTIER - What is Prettier? Prettier is an opinionated code formatter

prettier(yourcode) {
    log("Your Code in prettier format");
}
@ankur-anand
ankur-anand / laverna Setup
Created January 1, 2018 13:25
laverna custom launcher
[Desktop Entry]
Version=1.0
Type=Application
Name=Laverna
GenericName=Text Editor
Comment=Live private markdown editing and notes
Exec=/opt/laverna-0.7.51-linux-x64/laverna
Terminal=false
MimeType=text/plain;
Icon=/opt/laverna-0.7.51-linux-x64/resources/app/dist/images/icon/icon.png
@ankur-anand
ankur-anand / flash-app.js
Created September 19, 2017 19:03 — forked from brianmacarthur/flash-app.js
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@ankur-anand
ankur-anand / example1.js
Created September 9, 2017 10:04
Non-deterministic order of execution of setTimeout vs setImmediate in node.js event-loop
setTimeout(function timeout () {
 console.log(‘timeout’);
},0);
setImmediate(function immediate () {
 console.log(‘immediate’);
});
@ankur-anand
ankur-anand / concurrency-in-go.md
Created November 14, 2016 13:50 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
@ankur-anand
ankur-anand / go-channels-1-generator.go
Created November 14, 2016 13:49 — forked from kachayev/go-channels-1-generator.go
Channels-driven concurrency with Go
// Channels-driven concurrency with Go
// Code examples from Rob Pike's talk on Google I/O 2012:
// http://www.youtube.com/watch?v=f6kdp27TYZs&feature=youtu.be
//
// Concurrency is the key to designing high performance network services.
// Go's concurrency primitives (goroutines and channels) provide a simple and efficient means
// of expressing concurrent execution. In this talk we see how tricky concurrency
// problems can be solved gracefully with simple Go code.
// (1) Generator: function that returns the channel