bun
bun copied to clipboard
node:https.require() errors while evaluating 'globalThis.location.protocol'
trafficstars
What version of Bun is running?
0.2.2
What platform is your computer?
Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64 arm
What steps can reproduce the bug?
This can be run as-is, with the redacted values. It fails during the parse stage, before the request stage.
'use strict';
let https = require('node:https');
let resp = https.request({
protocol: 'https:',
slashes: true,
auth: 'AC[redacted]:[redacted]',
host: 'api.twilio.com',
port: null,
hostname: 'api.twilio.com',
hash: null,
search: null,
query: null,
pathname: '/2010-04-01/Accounts/AC[redacted]/Messages.json',
path: '/2010-04-01/Accounts/AC[redacted]/Messages.json',
href: 'https://api.twilio.com/2010-04-01/Accounts/AC[redacted]/Messages.json',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': '@root+request/1.8.0 bun/18.10.1 darwin/21.6.0 Darwin/arm64',
'Content-Length': 84,
},
});
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior?
Shouldn't have an error. Should use the protocol from the provided url, not globalThis.
What do you see instead?
TypeError: undefined is not an object (evaluating 'globalThis.location.protocol')
at /bun-vfs/node_modules/https/index.js:2:7325
at /Users/aj/Projects/Savvi/server/test.js:5:11
Additional information
No response
Thanks for reporting, this is likely an issue with our polyfill for node:https.
This was fixed around 6 months ago