awslabs / llrt

LLRT (Low Latency Runtime) is an experimental, lightweight JavaScript runtime designed to address the growing demand for fast and efficient Serverless applications.
Apache License 2.0
8.15k stars 359 forks source link

tty library missing #620

Closed paul-uz closed 2 days ago

paul-uz commented 1 month ago

I am trying to use the following package https://www.npmjs.com/package/@opensearch-project/opensearch?activeTab=readme but I'm currently blocked due to the tty library not being supported.

Being able to use this package is of great importance, as AWS do not have a true "client" library for OS (the one in the v3 SDK if for management of OS services, not for running queries).

Other than trying to get the OS package authors to remove the dependency on the packages that need tty, how can I resolve this?

paul-uz commented 1 month ago

Looks like there are other issues with that package, which i hit after stubbing tty.

I got a similar error to this one https://github.com/awslabs/llrt/issues/608

nabetti1720 commented 1 month ago

I have done some research as well. As you have pointed out, there seem to be some issues.

The following modules and functions are not implemented:

And even if you could implement these, you would probably get an error at this line. This is issue #608 itself.

module.exports = require('./common')(exports);
nabetti1720 commented 1 month ago

@paul-uz , As LLRT's Node.js package reading becomes browser-first, the required modules are changing. I already no longer need tty and util on my laptop. Currently, the required components are as follows.

node_modules/@opensearch-project/opensearch/lib/Transport.js:

There may be more, but first I will share where we are. :)

P.S. If you are using bundler, I recommend you to use platform: “browser” as it has a better chance of working.

paul-uz commented 1 month ago

@paul-uz , As LLRT's Node.js package reading becomes browser-first, the required modules are changing. I already no longer need tty and util on my laptop. Currently, the required components are as follows.

node_modules/@opensearch-project/opensearch/lib/Transport.js:

  • os.arch()
  • Buffer.constants.MAX_LENGTH
  • Buffer.constants.MAX_STRING_LENGTH
  • v8.getHeapStatistics().heap_size_limit

There may be more, but first I will share where we are. :)

P.S. If you are using bundler, I recommend you to use platform: “browser” as it has a better chance of working.

Sorry, what does this mean exactly?

Also, I thought you had to use browser as the platform for LLRT anyway?

nabetti1720 commented 1 month ago

I can't say it will necessarily work with that, but it is worth a try.

For reference, the @aws-sdk bundled inside LLRT is built with platform: “browser”. I believe this is to avoid Node.js-specific implementations included in @aws-sdk and @smithy, and to use the browser-oriented implementation.

The same could be said for general packages. However, if the package is not prepared with a browser-oriented implementation, this approach makes no sense.

ahaoboy commented 1 week ago

There are many libraries that require the isatty function, such as https://github.com/chalk/chalk

import tty from 'node:tty';

const supportsColor = {
    stdout: createSupportsColor({isTTY: tty.isatty(1)}),
    stderr: createSupportsColor({isTTY: tty.isatty(2)}),
};
richarddavison commented 2 days ago

Basic support added in https://github.com/awslabs/llrt/pull/675