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

unref() missing on HttpServer #4333

Closed
weyert opened this issue Aug 25, 2023 · 4 comments · Fixed by #8675
Closed

unref() missing on HttpServer #4333

weyert opened this issue Aug 25, 2023 · 4 comments · Fixed by #8675
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@weyert
Copy link
Contributor

weyert commented Aug 25, 2023

What version of Bun is running?

1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

Create a file with the following content:

require('http').createServer().unref()

Gives an error:

bun run ./poef.js
1 |
2 |   require("node:http").createServer().unref();
     ^
TypeError: require("node:http").createServer().unref is not a function. (In 'require("node:http").createServer().unref()', 'require("node:http").createServer().unref' is undefined)
      at /Users/weyert/poef.js:1:0
      at globalThis (/Users/weyert/poef.js:1:37)

What is the expected behavior?

I would expect the error not to be thrown

What do you see instead?

TypeError: require("node:http").createServer().unref is not a function. (In 'require("node:http").createServer().unref()', 'require("node:http").createServer().unref' is undefined)

Additional information

I was trying out whether OpenTelemetry is working through Bun but I am getting the above error when trying to create an instance of the PrometheusError which uses the above unref() call.

Original error I received was:

88 |         this._appendTimestamp =
89 |             typeof config.appendTimestamp === 'boolean'
90 |                 ? config.appendTimestamp
91 |                 : PrometheusExporter.DEFAULT_OPTIONS.appendTimestamp;
92 |         // unref to prevent prometheus exporter from holding the process open on exit
93 |         this._server = (0, http_1.createServer)(this._requestHandler).unref();
                ^
TypeError: (0, http_1.createServer)(this._requestHandler).unref is not a function. (In '(0, http_1.createServer)(this._requestHandler).unref()', '(0, http_1.createServer)(this._requestHandler).unref' is undefined)
      at new PrometheusExporter (/Users/weyert/Development/Project/node_modules/.pnpm/@opentelemetry+exporter-prometheus@0.41.2_@opentelemetry+api@1.4.1/node_modules/@opentelemetry/exporter-prometheus/build/src/PrometheusExporter.js:93:13)
      at configureMetricExporter (/Users/weyert/Development/Project/packages/opentelemetry-launcher/dist/launcher.js:356:30)
      at configureOpenTelemetry (/Users/weyert/Development/Project/packages/opentelemetry-launcher/dist/launcher.js:111:4)
      at /Users/weyert/Development/Project/services/service/dist/bootstrap.js:43:12
      at globalThis (/Users/weyert/Development/Project/services/service/dist/boot
@weyert weyert added the bug Something isn't working label Aug 25, 2023
@weyert
Copy link
Contributor Author

weyert commented Sep 8, 2023

For an example, how it is used in a production project:
https://github.com/weyert/bun-opentelemetry/blob/main/README.md

Retested in 1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49 still occurs

@cs01
Copy link

cs01 commented Oct 6, 2023

I just ran into this on 1.0.4.

@Electroid Electroid added the node.js Compatibility with Node.js APIs label Oct 27, 2023
@MarcStdt
Copy link

Still an issue in 1.0.20.
This breaks the usage of open-telemetry (prometheus exporter) for me.

@chlorophant
Copy link

Still an issue for me as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants