Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove AsyncLocalStorage check #6147

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ unreleased
========================

* Remove `Object.setPrototypeOf` polyfill
* cleanup: remove AsyncLocalStorage check from tests
* cleanup: remove unnecessary require for global Buffer


5.0.1 / 2024-10-08
==========

Expand Down
19 changes: 4 additions & 15 deletions test/express.json.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage

var express = require('..')
var request = require('supertest')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('express.json()', function () {
it('should parse JSON', function (done) {
request(createApp())
Expand Down Expand Up @@ -502,13 +499,13 @@ describe('express.json()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var app = express()
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand Down Expand Up @@ -755,11 +752,3 @@ function shouldContainInBody (str) {
'expected \'' + res.text + '\' to contain \'' + str + '\'')
}
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
19 changes: 4 additions & 15 deletions test/express.raw.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage

var express = require('..')
var request = require('supertest')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('express.raw()', function () {
before(function () {
this.app = createApp()
Expand Down Expand Up @@ -327,13 +324,13 @@ describe('express.raw()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var app = express()
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand Down Expand Up @@ -513,11 +510,3 @@ function createApp (options) {

return app
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
19 changes: 4 additions & 15 deletions test/express.text.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage

var express = require('..')
var request = require('supertest')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('express.text()', function () {
before(function () {
this.app = createApp()
Expand Down Expand Up @@ -360,13 +357,13 @@ describe('express.text()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var app = express()
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand Down Expand Up @@ -567,11 +564,3 @@ function createApp (options) {

return app
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
19 changes: 4 additions & 15 deletions test/express.urlencoded.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage

var express = require('..')
var request = require('supertest')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('express.urlencoded()', function () {
before(function () {
this.app = createApp()
Expand Down Expand Up @@ -605,13 +602,13 @@ describe('express.urlencoded()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var app = express()
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand Down Expand Up @@ -828,11 +825,3 @@ function expectKeyCount (count) {
assert.strictEqual(Object.keys(JSON.parse(res.text)).length, count)
}
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
21 changes: 5 additions & 16 deletions test/res.download.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

var after = require('after');
var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage

var express = require('..');
var path = require('path')
var request = require('supertest');
var utils = require('./support/utils')

var FIXTURES_PATH = path.join(__dirname, 'fixtures')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('res', function(){
describe('.download(path)', function(){
it('should transfer as an attachment', function(done){
Expand Down Expand Up @@ -90,14 +87,14 @@ describe('res', function(){
.expect(200, cb);
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
it('should presist store', function (done) {
var app = express()
var cb = after(2, done)
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand All @@ -124,7 +121,7 @@ describe('res', function(){
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand Down Expand Up @@ -487,11 +484,3 @@ describe('res', function(){
})
})
})

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
21 changes: 5 additions & 16 deletions test/res.sendFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

var after = require('after');
var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage

var express = require('../')
, request = require('supertest')
var onFinished = require('on-finished');
var path = require('path');
var fixtures = path.join(__dirname, 'fixtures');
var utils = require('./support/utils');

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('res', function(){
describe('.sendFile(path)', function () {
it('should error missing path', function (done) {
Expand Down Expand Up @@ -266,14 +263,14 @@ describe('res', function(){
.expect(200, 'got 404 error', done)
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
it('should presist store', function (done) {
var app = express()
var cb = after(2, done)
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand All @@ -299,7 +296,7 @@ describe('res', function(){
var store = { foo: 'bar' }

app.use(function (req, res, next) {
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
req.asyncLocalStorage = new AsyncLocalStorage()
req.asyncLocalStorage.run(store, next)
})

Expand Down Expand Up @@ -900,11 +897,3 @@ function createApp(path, options, fn) {

return app;
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
Loading