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.4k
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
730
Programming flying robots with JavaScript
felixge
2
910
Programming flying robots with JavaScript
felixge
0
550
Programming an AR Drone Firmware with JS (de)
felixge
1
580
Faster than C?
felixge
1
1.2k
Flying robots over a 10.000 mile distance with JavaScript.
felixge
0
450
Faster than C?
felixge
1
580
The power of node.js (with quadcopters)
felixge
0
460
Faster than C?
felixge
0
370
Other Decks in Technology
See All in Technology
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
31k
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
420
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
520
5分でわかるDuckDB
chanyou0311
10
3.2k
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
CustomCopを使ってMongoidのコーディングルールを整えてみた
jinoketani
0
220
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
370
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
220
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
840
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
250
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
210
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The Cost Of JavaScript in 2023
addyosmani
45
7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
We Have a Design System, Now What?
morganepeng
51
7.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Code Reviewing Like a Champion
maltzj
520
39k
How to Ace a Technical Interview
jacobian
276
23k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Making Projects Easy
brettharned
116
5.9k
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