-
Notifications
You must be signed in to change notification settings - Fork 29
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
clients/viem: use interval for routine fetching, unref intervalId #383
Conversation
✅ Deploy Preview for oasisprotocol-sapphire-paratime ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This won't work in browsers. We can do something like: if( typeof x === 'object' && 'unref' in x && typeof x.unref == 'function' ) or just if( typeof x.unref === 'function' ) ? Likewise we're not doing any in-browser testing for packages which will primarily be used in browsers, so none of this would've been caught in CI. |
Will find a way of linting the TS code for NodeJS vs WebBrowser compatibility. |
c0294a6
to
83d5ae5
Compare
Have logged a ticket/discussion with Viem w.r.t async serializers, which would entirely avoid this hacky workaround. I should've done this earlier. |
A standalone NodeJS script reproduces the exit error pretty easily, but reproducing it in const transport = sapphireHttpTransport();
const chain = sapphireLocalnet;
const publicClient = createPublicClient({ chain, transport });
defineChain({
id: 0x5afd,
name: "Oasis Sapphire Localnet",
network: "sapphire-localnet",
nativeCurrency: { name: "Sapphire Local Rose", symbol: "TEST", decimals: 18 },
rpcUrls: {
default: {
http: ["http://localhost:8545"],
},
},
serializers: {
transaction: createSapphireSerializer(publicClient)
},
testnet: true,
}); |
Ok, I can reproduce this. Have added a timeout test, to verify that your example script exits after 2 seconds. |
c6baba3
to
9d987c4
Compare
9d987c4
to
c34b198
Compare
Provide actual fix for problem inside #379