%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
'use strict'; const common = require('../common'); const sleep = require('util').promisify(setTimeout); const assert = require('assert'); const { executionAsyncResource, createHook } = require('async_hooks'); const { createServer, get } = require('http'); const sym = Symbol('cls'); // Tests continuation local storage with the currentResource API // through an async function assert.ok(executionAsyncResource()); createHook({ init(asyncId, type, triggerAsyncId, resource) { const cr = executionAsyncResource(); resource[sym] = cr[sym]; } }).enable(); async function handler(req, res) { executionAsyncResource()[sym] = { state: req.url }; await sleep(10); const { state } = executionAsyncResource()[sym]; res.setHeader('content-type', 'application/json'); res.end(JSON.stringify({ state })); } const server = createServer(function(req, res) { handler(req, res); }); function test(n) { get(`http://localhost:${server.address().port}/${n}`, common.mustCall(function(res) { res.setEncoding('utf8'); let body = ''; res.on('data', function(chunk) { body += chunk; }); res.on('end', common.mustCall(function() { assert.deepStrictEqual(JSON.parse(body), { state: `/${n}` }); })); })); } server.listen(0, common.mustCall(function() { server.unref(); for (let i = 0; i < 10; i++) { test(i); } }));