bun icon indicating copy to clipboard operation
bun copied to clipboard

Implement Node's "tls" module

Open BlackComplexx opened this issue 3 years ago • 13 comments
trafficstars

Version

0.1.4

Platform

Linux ubuntu 5.4.0-121-generic #137-Ubuntu SMP Wed Jun 15 13:33:07 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

What steps will reproduce the bug?

Requiring and trying to use the nodejs "tls" module doesn't work Screenshot_1 .

Code:

import tls from "node:tls" console.log(tls.getCiphers())

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

receive the Cipher list as a string.

What do you see instead?

TypeError: undefined is not an object (evaluating 'tls.getCiphers')

Additional information

No response

BlackComplexx avatar Jul 18 '22 17:07 BlackComplexx

node's tls module isn't implemented yet

Jarred-Sumner avatar Jul 20 '22 06:07 Jarred-Sumner

👀 following this one.

jmordica avatar Aug 06 '22 16:08 jmordica

I do not understand why this is marked as "enhancement". So far as I understand, one of the Bun project goals is a complete implementation of Node.js. The TLS package is built-in to Node.js, and is widely used. This should instead be considered a high priority bug.

FWIW I came across this not because my code uses TLS directly, but because some code in my application ends up using the forever-agent package, which in turn requires TLS, which fails this way:

error: Cannot find package "tls" from "/home/david/Projects/akasharender/akashacms-perftest/node_modules/forever-agent/index.js"

robogeek avatar Aug 12 '22 18:08 robogeek

does anyone knows if this has been solved already in Bun? I get the same error when installing mysql2

error: Cannot find package "tls" from "/Users/user/Documents/bun/node_modules/mysql2/lib/connection.js"

otonielcarlos avatar Aug 24 '22 17:08 otonielcarlos

I am getting the same error too error: Cannot find package "tls" from ... when importing mysql

tildekarthik avatar Oct 25 '22 15:10 tildekarthik

Bump on this, tls is a really important package

naive17 avatar Oct 26 '22 09:10 naive17

Bump - we'd love to switch and can't because of this.

philippzentner avatar Nov 15 '22 00:11 philippzentner

puppeteer and playwright also depend on this

meepeek avatar Dec 08 '22 14:12 meepeek

I've tried to run a nest app and this package is missing too :/

sostenesapollo avatar Dec 08 '22 18:12 sostenesapollo

Having the same issue with a toy websocket app.

shaneafsar avatar Dec 15 '22 23:12 shaneafsar

Do someone have any update ?

sostenesapollo avatar Dec 16 '22 13:12 sostenesapollo

Bump. Cannot use Bun because of this issue. My app uses node-redis which relies on Node's tls module.

skibitsky avatar Dec 28 '22 11:12 skibitsky

Thank you for bumping

We need net's Socket to work first. It will be a wrapper around Bun.connect & Bun.listen. The actual work involved to implement this won't be huge.

Jarred-Sumner avatar Dec 28 '22 11:12 Jarred-Sumner

In Bun v0.5.1 TLS error disappear. But now I have another error:

21 |   "node_modules/inherits/inherits_browser.js"(exports, module2) {
22 |     module2.exports = function inherits(ctor, superCtor) {
23 |       ctor.super_ = superCtor;
24 | 
25 |       ctor.prototype = Object.create(superCtor.prototype, {
                                        ^
TypeError: undefined is not an object (evaluating 'superCtor.prototype')
      at inherits (node:util:25:37)
      at /project_path.../node_modules/forever-agent/index.js:54:0
      at /project_path.../node_modules/request/request.js:14:4
      at /project_path.../node_modules/request/index.js:143:8

Error comes using danfojs-node I don't know if it's a problem with bun or the dependency itself

xavikortes avatar Jan 24 '23 10:01 xavikortes

Great that there is some progress here :+1:

However, with bun v5.5 , trying to run playwright produces another error (not sure if tls-related):

Error:

1 | import { chromium } from "@playwright/test";
3 | const browser = await chromium.launch();
                           ^
TypeError: undefined is not an object (evaluating 'chromium.launch')

Reproducing is simple:

package.json:

{
  "dependencies": {
    "@playwright/test": "1.30.0",
    "@playwright/test-runner": "0.9.24"
  },
  "type": "module"
}

main.ts:

import { chromium } from "@playwright/test";
const browser = await chromium.launch();

And then simply run

  • bun install
  • npx playwright install
  • bun main.ts

Dan1ve avatar Feb 03 '23 15:02 Dan1ve

I was trying to use bun, but I think this stops me for now. I got into this problem when using nodemailer for the first time. Thanks for the progress though.

ahmafi avatar Mar 23 '23 16:03 ahmafi

A lot more of tls is implemented since this issue was last updated (mysql2 works, for example), including parts of

  • createServer
  • connect

Bun internally doesn’t compose the way node does which means things like https is supported even if not all of tls is implemented

Jarred-Sumner avatar Jul 12 '23 11:07 Jarred-Sumner