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
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
760
Programming flying robots with JavaScript
felixge
2
930
Programming flying robots with JavaScript
felixge
0
570
Programming an AR Drone Firmware with JS (de)
felixge
1
600
Faster than C?
felixge
1
1.2k
Flying robots over a 10.000 mile distance with JavaScript.
felixge
0
460
Faster than C?
felixge
1
610
The power of node.js (with quadcopters)
felixge
0
470
Faster than C?
felixge
0
400
Other Decks in Technology
See All in Technology
日本MySQLユーザ会ができるまで / making MyNA
tmtms
1
180
Redefine_Possible
upsider_tech
0
160
バックエンドエンジニアによるフロントエンドテスト拡充の具体的手法
kinosuke01
1
470
fukuoka.ts #3 社内でESLintの共通設定を配りたい2025年春版
pirosikick
1
280
Vision Language Modelを活用した メルカリの類似画像レコメンドの性能改善
yadayuki
9
1k
これからクラウドエンジニアになるために本当に必要なスキル 5選
hiyanger
1
440
VISITS_20250311_こねくとあいとりおす.pdf
iotcomjpadmin
0
220
Dapr For Java Developers SouJava 25
salaboy
1
120
【Oracle Cloud ウェビナー】VMware環境を短期間でクラウド化!ベネッセ様事例に学ぶ仮想環境クラウド移行のリアル
oracle4engineer
PRO
2
120
モジュラーモノリスでスケーラブルなシステムを作る - BASE のリアーキテクチャのいま
panda_program
7
1.7k
ランチの間に GitHub Copilot Agent が仕事を終わらせてくれた話
bicstone
5
690
Engineering Managementのグローバルトレンド #emoasis / Engineering Management Global Trend
kyonmm
PRO
6
910
Featured
See All Featured
Code Review Best Practice
trishagee
67
18k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
A Philosophy of Restraint
colly
203
16k
The Cost Of JavaScript in 2023
addyosmani
48
7.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
We Have a Design System, Now What?
morganepeng
51
7.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Practical Orchestrator
shlominoach
186
10k
Building Your Own Lightsaber
phodgson
104
6.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.4k
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