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

No bun.js support #1120

Closed
Elektroplayer opened this issue Sep 12, 2023 · 5 comments
Closed

No bun.js support #1120

Elektroplayer opened this issue Sep 12, 2023 · 5 comments

Comments

@Elektroplayer
Copy link

Bug Report

I have read:

I am using the latest version of the library.

I am start this code with bun 1.0.0.

import TelegramBot from "node-telegram-bot-api";

const bot = new TelegramBot(process.env.TOKEN, { polling: true });

Expected Behavior

Bot starts

Actual Behavior

Bot not starts with this error:

> bun .
[0.05ms] ".env"
1 | (function (process,nextTickQueue,drainMicrotasksFn,reportUncaughtExceptionFn){"use strict";var queue,process,nextTickQueue=nextTickQueue,drainMicrotasks=drainMicrotasksFn,reportUncaughtException=reportUncaughtExceptionFn;function validateFunction(cb){if(typeof cb!=="function"){const err=@makeTypeError(`The "callback" argument must be of type "function". Received type ${typeof cb}`);throw err.code="ERR_INVALID_ARG_TYPE",err}}var setup=()=>{queue=function createQueue(){class FixedCircularBuffer{constructor(){this.bottom=0,this.top=0,this.list=@newArrayWithSize(2048),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&2047)===this.bottom}push(data){this.list[this.top]=data,this.top=this.top+1&2047}shift(){var{list,bottom}=this;const nextItem=list[bottom];if(nextItem===@undefined)return null;return list[bottom]=@undefined,this.bottom=bottom+1&2047,nextItem}}class FixedQueue{constructor(){this.head=this.tail=new FixedCircularBuffer}isEmpty(){return this.head.isEmpty()}push(data){if(this.head.isFull())this.head=this.head.next=new FixedCircularBuffer;this.head.push(data)}shift(){const tail=this.tail,next=tail.shift();if(tail.isEmpty()&&tail.next!==null)this.tail=tail.next,tail.next=null;return next}}return new FixedQueue}();function processTicksAndRejections(){var tock;do{while((tock=queue.shift())!==null){var{callback,args,frame}=tock,restore=@getInternalField(@asyncContext,0);@putInternalField(@asyncContext,0,frame);try{if(args===@undefined)callback();else switch(args.length){case 1:callback(args[0]);break;case 2:callback(args[0],args[1]);break;case 3:callback(args[0],args[1],args[2]);break;case 4:callback(args[0],args[1],args[2],args[3]);break;default:callback(...args);break}}catch(e){reportUncaughtException(e)}finally{@putInternalField(@asyncContext,0,restore)}}drainMicrotasks()}while(!queue.isEmpty())}@putInternalField(nextTickQueue,0,0),@putInternalField(nextTickQueue,1,queue),@putInternalField(nextTickQueue,2,processTicksAndRejections),setup=@undefined};function nextTick(cb,args){if(validateFunction(cb),setup)setup(),process=globalThis.process;if(process._exiting)return;queue.push({callback:cb,args:@argumentCount()>1?@Array.prototype.slice.@call(arguments,1):@undefined,frame:@getInternalField(@asyncContext,0)}),@putInternalField(nextTickQueue,0,1)}return nextTick})
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
TypeError: Requested module is not instantiated yet.
      at processTicksAndRejections (:1:2602)

Steps to reproduce the Behavior

bun 1.0.0
library 0.63.0
bun .

@melroy89
Copy link
Contributor

I got the same problem. Very strange issue. Bun should be a drop-in replacement, maybe it's a bug in Bun. Could you create an issue at bun as well?

@Elektroplayer
Copy link
Author

oven-sh/bun#5144

@melroy89
Copy link
Contributor

melroy89 commented Sep 13, 2023

Root cause is because we still use request-promise package! Which is outdated, has vurnabilities and now also doesn't work with bun...

See also: #1076

Move away from request-promise asap! Plz.

@melroy89
Copy link
Contributor

Can somebody retest with Bun 1.0.2?

@Elektroplayer
Copy link
Author

Tested for about five minutes. The bot starts and seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants