Skip to content
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

postLeafAndGetTimestamp sometimes crashes #28

Closed
foolo opened this issue May 15, 2024 · 1 comment
Closed

postLeafAndGetTimestamp sometimes crashes #28

foolo opened this issue May 15, 2024 · 1 comment

Comments

@foolo
Copy link

foolo commented May 15, 2024

It seems like the server sometimes replies with an error page <!DOCTYPE html>..., which postLeafAndGetTimestamp in WitnessClient doesn't handle, and a SyntaxError is thrown to the application.

Steps to reproduce (happens maybe 1 out of 1000 calls or so):

const witness = new WitnessClient(process.env.WITNESS_API_KEY);
const leafHash = witness.hash("...");
let timestamp = await witness.postLeafAndGetTimestamp(leafHash);

Result:

undefined:1
<!DOCTYPE html>
^

SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)
    at successSteps (node:internal/deps/undici/undici:5555:27)
    at fullyReadBody (node:internal/deps/undici/undici:1665:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)
    at async w.getLatestOnchainCheckpoint (/home/olof_andersson/dkim-lookup/dkim-lookup-app/node_modules/.pnpm/@witnessco+client@0.1.14_viem@2.8.18/node_modules/@witnessco/client/dist/index.cjs:1:10868)
    at async w.waitForCheckpointedLeafHash (/home/olof_andersson/dkim-lookup/dkim-lookup-app/node_modules/.pnpm/@witnessco+client@0.1.14_viem@2.8.18/node_modules/@witnessco/client/dist/index.cjs:1:8828)
    at async w.postLeafAndGetTimestamp (/home/olof_andersson/dkim-lookup/dkim-lookup-app/node_modules/.pnpm/@witnessco+client@0.1.14_viem@2.8.18/node_modules/@witnessco/client/dist/index.cjs:1:9550)
    at async generateWitness (/home/olof_andersson/dkim-lookup/dkim-lookup-app/src/lib/generateWitness.ts:2:1306)

@sina-wit
Copy link
Contributor

This should be fixed based on a previous version release; closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants