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

Bun types report wrong https createServer options. #7052

Open
bdotsamir opened this issue Nov 11, 2023 · 1 comment
Open

Bun types report wrong https createServer options. #7052

bdotsamir opened this issue Nov 11, 2023 · 1 comment
Labels
bug Something isn't working typescript Something for TypeScript

Comments

@bdotsamir
Copy link

What version of Bun is running?

1.0.11+f7f6233ea

What platform is your computer?

Darwin 23.2.0 arm64 arm

What steps can reproduce the bug?

Creating an https server with node:https reports that options key and cert are invalid, despite stating in the official node https documentation to include key and cert.

Bun does actually create the https server with the certificate details perfectly fine, however it appears that the https module typings actually points to the http module typings.

import { createServer as createHTTPS_Server } from "node:https";
import { readFileSync } from "node:fs";

import { createServer as createHTTP_Server } from "node:http";

createHTTP_Server({
  keepAlive: true
}, (req, res) => {
  res.writeHead(200);
  res.end('hello HTTP\n');
}).listen(8001, () => console.log('HTTP listening on 8001'));

createHTTPS_Server({
  keepAlive: true, // Totally fine!
  key: readFileSync('./keys/ssl-cert-snakeoil.key'), // <-- red underline
  cert: readFileSync('./keys/ssl-cert-snakeoil.pem'), // <-- red underline
}, (req, res) => {
  res.writeHead(200);
  res.end('hello HTTPS\n');
}).listen(8000, () => console.log('HTTPS listening on 8000')); 

What is the expected behavior?

Correct typings lol

What do you see instead?

TSC yelling at me that key and cert are not valid.

Additional information

The reason I am not using Bun.serve() with the TLS options is that when I get a new request, I cannot then check the client's certificate. I am creating an application that relies on this functionality, and Bun does not implement this in the native Bun.serve() api (from what I've seen).

@bdotsamir bdotsamir added the bug Something isn't working label Nov 11, 2023
@bdotsamir bdotsamir changed the title Bun types report wrong https createServer options typing. Bun types report wrong https createServer options. Nov 11, 2023
@Electroid Electroid added the typescript Something for TypeScript label Nov 13, 2023
@david-plugge
Copy link

This is weird! If you import from https (without the node prefix) you don't get the ts error.
BUT it doesnt work with request from https! Bun completely ignores that i set the cert and key properties and this results in a 401. It does work with node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript Something for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants