✅ Prerequisites
🐛 Description
In the farcaster docs (https://magic.link/docs/authentication/login/farcaster#example) we have:
import { Magic } from 'magic-sdk';
import { FarcasterExtension } from '@magic-ext/farcaster';
const magic = new Magic('YOUR_API_KEY', {
extensions: [new FarcasterExtension()],
});
try {
await magic.farcaster.login();
} catch {
// Handle errors or reject if required!
}
But note that this sometimes fails if the request doesn't go through before login is called due to the async nature of the constructor:
(@magic-ext/farcaster/src/index.ts)
export class FarcasterExtension
...
constructor() {
super();
(async () => {
this.channel = await fetch(`${FARCASTER_RELAY_URL}/v1/channel`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
domain: window.location.host,
siweUri: window.location.origin,
}),
}).then<CreateChannelAPIResponse>((r) => r.json());
})();
}
public login = (params?: LoginParams) => {
if (!this.channel) {
throw new Error('Channel not created yet.');
}
...
Note that in the case where the request in the constructor does not resolve before login is called, the error Channel not created yet. is thrown.
🧩 Steps to Reproduce
- Use the example in the docs
- Set network to 3G in browser dev tools
🤔 Expected behavior
Should work correctly and show the farcaster login UI
😮 Actual behavior
An error Channel not created yet. is thrown.
💻 Code Sample
[If possible, please provide a code repository, gist, code snippet or sample files to reproduce the issue.]
🌎 Environment
| Software |
Version(s) |
magic-sdk |
28.17.0 |
| Browser |
Chrome 130 |
pnpm |
9.12.3 |
| Operating System |
macos |
✅ Prerequisites
magic-sdk)?🐛 Description
In the farcaster docs (https://magic.link/docs/authentication/login/farcaster#example) we have:
But note that this sometimes fails if the request doesn't go through before login is called due to the async nature of the constructor:
(@magic-ext/farcaster/src/index.ts)
Note that in the case where the request in the constructor does not resolve before login is called, the error
Channel not created yet.is thrown.🧩 Steps to Reproduce
🤔 Expected behavior
Should work correctly and show the farcaster login UI
😮 Actual behavior
An error
Channel not created yet.is thrown.💻 Code Sample
[If possible, please provide a code repository, gist, code snippet or sample files to reproduce the issue.]
🌎 Environment
magic-sdkpnpm