oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.42k stars 2.78k forks source link

Type error when using winston-loki npm package #6072

Open rexdavid opened 1 year ago

rexdavid commented 1 year ago

What version of Bun is running?

1.0.3

What platform is your computer?

linux

What steps can reproduce the bug?

What is the expected behavior?

No errors thrown

What do you see instead?

Console output:

bun --watch ./src/start.ts

38 | // Load given options to the object 39 | this.options = options 40 | 41 | // Construct Grafana Loki push API url 42 | const URL = this.loadUrl() 43 | this.url = (new URL(this.options.host + '/loki/api/v1/push')) ^ TypeError: Type error at new Batcher (app/node_modules/winston-loki/src/batcher.js:43:16) at new LokiTransport (app/node_modules/winston-loki/index.js:21:19) at logTransports (app/src/loggers/logger.ts:34:4) at loggingTool (app/src/loggers/logger.ts:58:16) at app/src/schemaValidator.ts:29:15 at processTicksAndRejections (:55:76) 38 | // Load given options to the object 39 | this.options = options 40 | 41 | // Construct Grafana Loki push API url 42 | const URL = this.loadUrl() 43 | this.url = (new URL(this.options.host + '/loki/api/v1/push')) ^ TypeError: Type error at new Batcher (app/node_modules/winston-loki/src/batcher.js:43:16) at new LokiTransport (app/node_modules/winston-loki/index.js:21:19) at logTransports (app/src/loggers/logger.ts:34:4) at loggingTool (app/src/loggers/logger.ts:58:16) at app/src/schemaValidator.ts:29:15 at processTicksAndRejections (:55:76)

Additional information

No response

Electroid commented 1 year ago

Could you try again after running bun upgrade --canary? We recently improved the error message for URL parsing, and that should give us some additional info on why this is failing.

rexdavid commented 1 year ago

bun upgrade --canary

watch bun --watch ./src/start.ts

38 | // Load given options to the object 39 | this.options = options 40 | 41 | // Construct Grafana Loki push API url 42 | const URL = this.loadUrl() 43 | this.url = (new URL(this.options.host + '/loki/api/v1/push')) ^ TypeError: "undefined/loki/api/v1/push" cannot be parsed as a URL. at new Batcher (app/node_modules/winston-loki/src/batcher.js:43:16) at new LokiTransport (app/node_modules/winston-loki/index.js:21:19) at logTransports (app/src/loggers/logger.ts:34:4) at loggingTool (app/src/loggers/logger.ts:58:16) at app/src/schemaValidator.ts:29:15 at processTicksAndRejections (:55:76) 38 | // Load given options to the object 39 | this.options = options 40 | 41 | // Construct Grafana Loki push API url 42 | const URL = this.loadUrl() 43 | this.url = (new URL(this.options.host + '/loki/api/v1/push')) ^ TypeError: "undefined/loki/api/v1/push" cannot be parsed as a URL. at new Batcher (app/node_modules/winston-loki/src/batcher.js:43:16) at new LokiTransport (app/node_modules/winston-loki/index.js:21:19) at logTransports (app/src/loggers/logger.ts:34:4) at loggingTool (app/src/loggers/logger.ts:58:16) at app/src/schemaValidator.ts:29:15 at processTicksAndRejections (:55:76)

nektro commented 6 months ago

does this still reproduce for you? it appears to be working on my end in Bun 1.1.10 (you may need to run bun upgrade)

github-actions[bot] commented 3 months ago

This issue is stale and may be closed due to inactivity. If you're still running into this, please leave a comment.