[api-extractor] Fails with EBADF when building typescript definition files on Node.js v21.3.0
W-A-James opened this issue · 2 comments
W-A-James commented
Summary
When trying to generate rolled up definition file, fails to write the definition file with EBADF
.
Repro steps
- Clone the js-bson repo
- Run
npm install
- Run
node ./node_modules/typescript/bin/tsc
- Run
npx api-extractor --typescript-compiler-folder node_modules/typescript --local
Expected result: Runs with no errors and produces bson.d.ts
successfully
Actual result: When run with --diagnostics
flag enabled
-> % npx api-extractor run --typescript-compiler-folder node_modules/typescript --local --diagnostics
api-extractor 7.36.4 - https://api-extractor.com/
Using configuration from ./api-extractor.json
Using custom TSDoc config from /home/wajames/js-bson/tsdoc.json
Analysis will use the bundled TypeScript version 5.0.4
============================================================
DIAGNOSTIC: Final prepared ExtractorConfig
============================================================
{
"projectFolder": "/home/wajames/js-bson",
"packageJson": {
"bin": null,
"dependencies": null,
"description": "A bson parser for node.js and the browser",
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@microsoft/api-extractor": "^7.36.4",
"@octokit/core": "^4.2.4",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-typescript": "^11.1.2",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^18.17.3",
"@types/sinon": "^10.0.16",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"benchmark": "^2.1.4",
"chai": "^4.3.7",
"chalk": "^5.3.0",
"dbx-js-tools": "github:mongodb-js/dbx-js-tools",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-no-bigint-usage": "file:etc/eslint/no-bigint-usage",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-tsdoc": "^0.2.17",
"magic-string": "^0.30.2",
"mocha": "10.2.0",
"node-fetch": "^3.3.2",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"rollup": "^3.27.2",
"sinon": "^15.2.0",
"sinon-chai": "^3.7.0",
"source-map-support": "^0.5.21",
"standard-version": "^9.5.0",
"tar": "^6.1.15",
"ts-node": "^10.9.1",
"tsd": "^0.28.1",
"typescript": "^5.0.4",
"typescript-cached-transpile": "0.0.6",
"uuid": "^9.0.0"
},
"homepage": null,
"license": "Apache-2.0",
"main": "./lib/bson.cjs",
"name": "bson",
"optionalDependencies": null,
"peerDependencies": null,
"private": null,
"scripts": {
"pretest": "npm run build",
"test": "npm run check:node && npm run check:web && npm run check:web-no-bigint",
"check:node": "WEB=false mocha test/node",
"check:tsd": "npm run build:dts && tsd",
"check:web": "WEB=true mocha test/node",
"check:web-no-bigint": "WEB=true NO_BIGINT=true mocha test/node",
"check:granular-bench": "npm run build:bench && node ./test/bench/etc/run_granular_benchmarks.js",
"check:spec-bench": "npm run build:bench && node ./test/bench/lib/spec/bsonBench.js",
"build:bench": "cd test/bench && npx tsc",
"build:ts": "node ./node_modules/typescript/bin/tsc",
"build:dts": "npm run build:ts && api-extractor run --typescript-compiler-folder node_modules/typescript --local && node etc/clean_definition_files.cjs",
"build:bundle": "rollup -c rollup.config.mjs",
"build": "npm run build:dts && npm run build:bundle",
"check:lint": "eslint -v && eslint --ext '.js,.ts' --max-warnings=0 src test && npm run build:dts && npm run check:tsd",
"format": "eslint --ext '.js,.ts' src test --fix",
"check:coverage": "nyc --check-coverage npm run check:node",
"prepare": "node etc/prepare.js",
"release": "standard-version -i HISTORY.md"
},
"typings": "bson.d.ts",
"tsdocMetadata": null,
"version": "6.2.0"
},
"packageFolder": "/home/wajames/js-bson",
"mainEntryPointFilePath": "/home/wajames/js-bson/lib/index.d.ts",
"bundledPackages": [],
"tsconfigFilePath": "/home/wajames/js-bson/tsconfig.json",
"overrideTsconfig": null,
"skipLibCheck": false,
"apiReportEnabled": false,
"reportFilePath": "/home/wajames/js-bson/etc/bson.api.md",
"reportTempFilePath": "/home/wajames/js-bson/temp/bson.api.md",
"apiReportIncludeForgottenExports": false,
"docModelEnabled": false,
"apiJsonFilePath": "/home/wajames/js-bson/temp/bson.api.json",
"docModelIncludeForgottenExports": false,
"projectFolderUrl": null,
"rollupEnabled": true,
"untrimmedFilePath": "",
"alphaTrimmedFilePath": "",
"betaTrimmedFilePath": "",
"publicTrimmedFilePath": "/home/wajames/js-bson/bson.d.ts",
"omitTrimmingComments": false,
"tsdocMetadataEnabled": false,
"tsdocMetadataFilePath": "",
"newlineKind": "\n",
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "error"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "error"
},
"ae-forgotten-export": {
"logLevel": "warning",
"addToApiReportFile": true
},
"ae-incompatible-release-tags": {
"logLevel": "warning",
"addToApiReportFile": true
},
"ae-internal-missing-underscore": {
"logLevel": "none",
"addToApiReportFile": false
},
"ae-internal-mixed-release-tag": {
"logLevel": "warning",
"addToApiReportFile": true
},
"ae-unresolved-inheritdoc-reference": {
"logLevel": "warning",
"addToApiReportFile": true
},
"ae-unresolved-inheritdoc-base": {
"logLevel": "warning",
"addToApiReportFile": true
},
"ae-wrong-input-file-type": {
"logLevel": "error"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "error"
}
}
},
"testMode": false,
"enumMemberOrder": "by-name",
"tsdocConfigFile": {
"filePath": "/home/wajames/js-bson/tsdoc.json",
"log": []
}
}
============================================================
============================================================
DIAGNOSTIC: Compiler options
============================================================
{
"allowJs": false,
"checkJs": false,
"strict": true,
"alwaysStrict": true,
"target": 8,
"module": 1,
"moduleResolution": 2,
"skipLibCheck": true,
"lib": [
"lib.es2021.d.ts"
],
"outDir": "/home/wajames/js-bson/lib",
"importHelpers": false,
"noEmitHelpers": false,
"noEmitOnError": true,
"emitDeclarationOnly": true,
"sourceMap": true,
"inlineSourceMap": false,
"inlineSources": false,
"declaration": true,
"declarationMap": true,
"types": [],
"isolatedModules": true,
"configFilePath": null
}
============================================================
============================================================
DIAGNOSTIC: TSDoc configuration
============================================================
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"noStandardTags": true,
"tagDefinitions": [
{
"tagName": "@alpha",
"syntaxKind": "modifier"
},
{
"tagName": "@beta",
"syntaxKind": "modifier"
},
{
"tagName": "@defaultValue",
"syntaxKind": "block"
},
{
"tagName": "@decorator",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@deprecated",
"syntaxKind": "block"
},
{
"tagName": "@eventProperty",
"syntaxKind": "modifier"
},
{
"tagName": "@example",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@experimental",
"syntaxKind": "modifier"
},
{
"tagName": "@inheritDoc",
"syntaxKind": "inline"
},
{
"tagName": "@internal",
"syntaxKind": "modifier"
},
{
"tagName": "@label",
"syntaxKind": "inline"
},
{
"tagName": "@link",
"syntaxKind": "inline",
"allowMultiple": true
},
{
"tagName": "@override",
"syntaxKind": "modifier"
},
{
"tagName": "@packageDocumentation",
"syntaxKind": "modifier"
},
{
"tagName": "@param",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@privateRemarks",
"syntaxKind": "block"
},
{
"tagName": "@public",
"syntaxKind": "modifier"
},
{
"tagName": "@readonly",
"syntaxKind": "modifier"
},
{
"tagName": "@remarks",
"syntaxKind": "block"
},
{
"tagName": "@returns",
"syntaxKind": "block"
},
{
"tagName": "@sealed",
"syntaxKind": "modifier"
},
{
"tagName": "@see",
"syntaxKind": "block"
},
{
"tagName": "@throws",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@typeParam",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@virtual",
"syntaxKind": "modifier"
},
{
"tagName": "@category",
"syntaxKind": "block"
}
],
"reportUnsupportedHtmlElements": false
}
============================================================
============================================================
DIAGNOSTIC: Root filenames
============================================================
/home/wajames/js-bson/lib/index.d.ts
============================================================
============================================================
DIAGNOSTIC: Files analyzed by compiler
============================================================
/home/wajames/js-bson/node_modules/typescript/lib/lib.es5.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2016.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2017.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2018.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2019.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2021.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.core.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.collection.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.generator.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.iterable.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.promise.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.proxy.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.reflect.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.symbol.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2016.array.include.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2017.object.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2017.string.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2017.intl.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2018.intl.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2018.promise.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2018.regexp.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2019.array.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2019.object.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2019.string.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2019.symbol.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2019.intl.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.bigint.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.date.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.promise.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.string.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.intl.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2020.number.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2021.promise.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2021.string.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2021.weakref.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.es2021.intl.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.decorators.d.ts
/home/wajames/js-bson/node_modules/typescript/lib/lib.decorators.legacy.d.ts
/home/wajames/js-bson/lib/parser/utils.d.ts
/home/wajames/js-bson/lib/extended_json.d.ts
/home/wajames/js-bson/lib/bson_value.d.ts
/home/wajames/js-bson/lib/binary.d.ts
/home/wajames/js-bson/lib/code.d.ts
/home/wajames/js-bson/lib/objectid.d.ts
/home/wajames/js-bson/lib/db_ref.d.ts
/home/wajames/js-bson/lib/decimal128.d.ts
/home/wajames/js-bson/lib/double.d.ts
/home/wajames/js-bson/lib/int_32.d.ts
/home/wajames/js-bson/lib/timestamp.d.ts
/home/wajames/js-bson/lib/long.d.ts
/home/wajames/js-bson/lib/max_key.d.ts
/home/wajames/js-bson/lib/min_key.d.ts
/home/wajames/js-bson/lib/parser/deserializer.d.ts
/home/wajames/js-bson/lib/parser/serializer.d.ts
/home/wajames/js-bson/lib/regexp.d.ts
/home/wajames/js-bson/lib/symbol.d.ts
/home/wajames/js-bson/lib/error.d.ts
/home/wajames/js-bson/lib/constants.d.ts
/home/wajames/js-bson/lib/bson.d.ts
/home/wajames/js-bson/lib/index.d.ts
============================================================
Ignoring reference to global variable "Uint8Array" in /home/wajames/js-bson/lib/bson.d.ts:55:82
Ignoring reference to global variable "Record" in /home/wajames/js-bson/lib/parser/deserializer.d.ts:61:25
Ignoring reference to global variable "Pick" in /home/wajames/js-bson/lib/bson.d.ts:75:42
Ignoring reference to global variable "ArrayBuffer" in /home/wajames/js-bson/lib/bson.d.ts:96:62
Ignoring reference to global variable "Date" in /home/wajames/js-bson/lib/objectid.d.ts:69:21
Ignoring reference to global variable "Exclude" in /home/wajames/js-bson/lib/timestamp.d.ts:7:11
Ignoring reference to global variable "Function" in /home/wajames/js-bson/lib/code.d.ts:22:32
Ignoring reference to global variable "Error" in /home/wajames/js-bson/lib/error.d.ts:9:40
Ignoring reference to global variable "Readonly" in /home/wajames/js-bson/lib/constants.d.ts:82:32
Writing package typings: /home/wajames/js-bson/bson.d.ts
ERROR: EBADF: bad file descriptor, write
Details
We have confirmed that this issue is not reproducible on Node 21.2.0 and earlier, so we suspect that the issue might have to do with something that changed in Node 21.3.0.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Question | Answer |
---|---|
@microsoft/api-extractor version? |
7.36.4 |
Operating system? | Ubuntu 20.04.6 |
API Extractor scenario? | rollups (.d.ts) |
Would you consider contributing a PR? | No |
TypeScript compiler version? | 5.0.4 |
Node.js version (node -v )? |
21.3.0 |
nbbeeken commented
Likely related to nodejs/node#50989, a fix appears to already be in progress.
W-A-James commented
Node v21.4.0 was released today which fixes this bug.