You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My deno test with grm fails, because my TelegramClient.invoke(…) is not finishing, but leaking some resource.
Try to run this test (with your own API_ID and API_HASH obviously) with deno test --allow-net:
import { superoak } from "https://deno.land/x/[email protected]/mod.ts";
import { Application, Router } from "https://deno.land/x/[email protected]/mod.ts";
import { StringSession, TelegramClient, Api } from "https://deno.land/x/[email protected]/mod.ts";
const API_ID = xxxx;
const API_HASH = 'yyyyyyy';
const telNo = `999662${Math.floor(1000 + Math.random() * 9000)}`;
function getApp() {
const router = new Router();
router.get('/', async c => {
const client = new TelegramClient(new StringSession(''), API_ID, API_HASH);
await client.connect();
await client.invoke(
new Api.auth.SendCode({
phoneNumber: telNo,
apiId: API_ID,
apiHash: API_HASH,
settings: new Api.CodeSettings({}),
})
);
c.response.body = 'hi';
});
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
return app;
}
Deno.test("Gram bug", async t => {
await t.step("GET /", async () => {
await (await superoak(getApp())).get("/").expect('hi');
});
});
I get this error message:
GET / ... FAILED (2s)
error: AssertionError: Test case is leaking async ops.
- 1 async operation to op_read was started in this test, but never completed.
- 2 async operations to sleep for a duration were started in this test, but never completed. This is often caused by not cancelling a `setTimeout` or `setInterval` call.
You can suppress this error with Deno.test options, but this only works for the first TelegramClient initalization. If you have multiple tests that do new TelegramClient, all tests except the first one fail with Telegram responding with 401: AUTH_KEY_UNREGISTERED.
Not sure if it is a bug that TelegramClient does not really finish itself, or if there is a command to do that (I tried TelegramClient.disconnect() and TelegramClient.destroy()).
The text was updated successfully, but these errors were encountered:
baumschubser
changed the title
Deno test is leaking async ops
TelegramClient is leaking async ops
Apr 1, 2023
Sorry for this example code that also involves oak and superoak. If we remove that and just have a test function like this, we don't get the error message but just a "failed" and a non-exiting test:
My deno test with grm fails, because my
TelegramClient.invoke(…)
is not finishing, but leaking some resource.Try to run this test (with your own API_ID and API_HASH obviously) with
deno test --allow-net
:I get this error message:
You can suppress this error with Deno.test options, but this only works for the first TelegramClient initalization. If you have multiple tests that do
new TelegramClient
, all tests except the first one fail with Telegram responding with 401: AUTH_KEY_UNREGISTERED.Not sure if it is a bug that TelegramClient does not really finish itself, or if there is a command to do that (I tried TelegramClient.disconnect() and TelegramClient.destroy()).
The text was updated successfully, but these errors were encountered: