Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Domains in node 0.8
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Felix Geisendörfer
June 29, 2012
Technology
8
5.5k
Domains in node 0.8
A quick presentation I gave at HolidayExtras on using the new domain feature in node.js 0.8.
Felix Geisendörfer
June 29, 2012
Tweet
Share
More Decks by Felix Geisendörfer
See All by Felix Geisendörfer
tus.io - Resumable File Uploads (Lightning Talk)
felixge
2
810
Programming flying robots with JavaScript
felixge
2
990
Programming flying robots with JavaScript
felixge
0
640
Programming an AR Drone Firmware with JS (de)
felixge
1
650
Faster than C?
felixge
1
1.3k
Flying robots over a 10.000 mile distance with JavaScript.
felixge
0
520
Faster than C?
felixge
1
690
The power of node.js (with quadcopters)
felixge
0
530
Faster than C?
felixge
0
460
Other Decks in Technology
See All in Technology
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
5
1.1k
EMからICへ、二周目人材としてAI全振りのプロダクト開発で見つけた武器
yug1224
5
510
楽しく学ぼう!コミュニティ入門 AWSと人が つむいできたストーリー
hiroramos4
PRO
1
180
組織全体で実現する標準監視設計
yuobayashi
2
470
DevOpsエージェントで実現する!! AWS Well-Architected(W-A) を実現するシステム設計 / 20260307 Masaki Okuda
shift_evolve
PRO
3
480
20260305_【白金鉱業】分析者が地理情報を武器にするための軽量なアドホック分析環境
yucho147
3
220
情シスのための生成AI実践ガイド2026 / Generative AI Practical Guide for Business Technology 2026
glidenote
0
190
Ultra Ethernet (UEC) v1.0 仕様概説
markunet
3
250
Kaggleの経験が実務にどう活きているか / kaggle_findy
sansan_randd
7
1.3k
Abuse report だけじゃない。AWS から緊急連絡が来る状況とは?昨今の攻撃や被害の事例の紹介と備えておきたい考え方について
kazzpapa3
1
390
8万デプロイ
iwamot
PRO
2
220
PMBOK第8版は第7版から何が変わったのか(PMBOK第8版概要解説) / 20260304 Takeshi Watarai
shift_evolve
PRO
0
180
Featured
See All Featured
How to Talk to Developers About Accessibility
jct
2
150
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How to make the Groovebox
asonas
2
2k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
170
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.1k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
140
Statistics for Hackers
jakevdp
799
230k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
エンジニアに許された特別な時間の終わり
watany
106
240k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Transcript
Domains in node 0.8 A quick introduction Freitag, 29. Juni
12
1 var app = require('express')(); 2 3 app.get('/search', function(req, res,
next) { 4 doSearch(req.params, function(err, result) { 5 if (err) return next(err); 6 7 // trying to access non-existing property 8 if (result.foo.bar) { 9 console.log('does not work'); 10 } 11 }); 12 }); 13 14 app.listen(8080); Freitag, 29. Juni 12
/Users/Felix/Desktop/domains/example.js:14 if (result.foo.bar) { ^ TypeError: Cannot read property 'bar'
of undefined at /Users/Felix/Desktop/domains/example.js:14:19 at doSearch (/Users/Felix/Desktop/domains/example.js:3:5) at process.startup.processNextTick.process._tickCallback (node.js:244:9) Freitag, 29. Juni 12
1 process.on('uncaughtException', function(err) { 2 // Keeps the process from
crashing 3 // But does not let you find out which `req` 4 // was causing the `err` 5 }); Freitag, 29. Juni 12
Domains to the rescue! Freitag, 29. Juni 12
1 var createDomain = require('domain').create; 2 3 app.use(function(req, res, next)
{ 4 var domain = createDomain(); 5 6 domain.on('error', function(err) { 7 // alternative: next(err) 8 res.statusCode = 500; 9 res.end(err.message + '\n'); 10 11 domain.dispose(); 12 }); 13 14 domain.enter(); 15 next(); 16 }); Freitag, 29. Juni 12
$ curl -i localhost:8080/search HTTP/1.1 500 Internal Server Error X-Powered-By:
Express Date: Fri, 29 Jun 2012 10:50:18 GMT Connection: keep-alive Transfer-Encoding: chunked Cannot read property 'bar' of undefined Freitag, 29. Juni 12
Questions? Freitag, 29. Juni 12
Hiring node.js developers @ marcgreenstock @dan_jenkins Freitag, 29. Juni 12