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/superoak@4.7.0/mod.ts";
import { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";
import { StringSession, TelegramClient, Api } from "https://deno.land/x/grm@0.8.0/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()).
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()).