eilvelia / tdl

Node.js bindings to TDLib 🥒
MIT License
394 stars 52 forks source link

prebuilt-tdlib 1.8.33 stopped working on macOS arm64 [codesigning] #165

Closed mugavri closed 1 month ago

mugavri commented 2 months ago

Seem like that Deno cannot run with tdlib-prebuilt version 1.8.33

Please check

eilvelia commented 2 months ago

Works for me. What are your system & arch, deno version, and what error are you experiencing?

mugavri commented 2 months ago

macOS 14.5 macbook air M2 deno: 1.45.2

code:

import * as tdl from "npm:tdl@8";
import { getTdjson } from "npm:prebuilt-tdlib@td-1.8.33";
// @ts-self-types="./tdlib-types.d.ts"

tdl.configure({ tdjson: getTdjson() });

const client = tdl.createClient({
    apiId: xxxx,
    apiHash: "xxx",
});

await client.login();

client.on("error", console.error);

const me = await client.invoke({ _: "getMe" });
console.log("I am", me);

await client.close();

run:

deno run --allow-read --allow-env --allow-ffi run.ts
zsh: killed     deno run --allow-read --allow-env --allow-ffi run.ts

work fine with:

import { getTdjson } from "npm:prebuilt-tdlib@td-1.8.30";
mugavri commented 2 months ago

I just checked It just doesn't work with prebuilt-tdlib version 1.8.33 Not even in node with js

package.json

{
  "dependencies": {
    "prebuilt-tdlib": "^0.1008033.0",
    "tdl": "^8.0.1"
  },
  "scripts": {
    "start": "node run.js"
  }
}

run.js

const tdl = require('tdl')
const { getTdjson } = require('prebuilt-tdlib')

tdl.configure({ tdjson: getTdjson() })

const client = tdl.createClient({
    apiId: xxxxx,
    apiHash: "xxxxx",
});

client.on('error', console.error)

async function main() {
    await client.login()

    console.log(await client.invoke({ _: 'getMe' }))

    await client.close()
}

main().catch(console.error)

terminal:

npm run start

> start
> node run.js

zsh: killed     npm run start

But works as expected with prebuilt-tdlib version 0.1008030.0

mugavri commented 2 months ago

seems like the problem in libtdjson.dylib file?

eilvelia commented 2 months ago

Thanks for the steps to reproduce. That could be the cause, given that there were lots of changes in prebuilt-tdlib between 1.8.30 and 1.8.33. Though that libtdjson.dylib is tested on GitHub Actions and works successfully on macOS 14 arm64 in the CI.

Are you sure you aren't running anything over rosetta? Could you add the following line at the start of run.js and show the output?

console.log(process.platform, process.arch)
eilvelia commented 1 month ago

I reproduced it on a M1 laptop. Funnily it works correctly in lldb.

The issue is that the signing of the libtdjson.dylib binary is incorrect, and codesigning is mandatory on arm64 macs. It will be fixed in the next release of prebuilt-tdlib. The temporary workaround is to do codesign -s - --force node_modules/@prebuilt-tdlib/darwin/libtdjson.dylib. GitHub Actions perhaps circumvents that somehow.

Thanks for reporting.

eilvelia commented 1 month ago

Try prebuilt-tdlib v0.1008033.1 (also published as the prebuilt-tdlib@td-1.8.33 tag), this issue should be fixed.

mugavri commented 1 month ago

i will check.

thank you!