Skip to content

Add error handling when request failed #16

Open

Description

@keung227
undefined:1
<html>
^

SyntaxError: Unexpected token < in JSON at position 0
    at IncomingMessage.<anonymous> (my_program_path\node_modules\bas-remote-node\src\utils.js:29:20)

There are some issues which force close my program when fetching fingerprint using "puppeteer-with-fingerprints"

Activity

  1. Firegarden commented on Jul 14, 2023

    @Firegarden

    I figured out what this is related to a dns resolution or ip address end point connectivity - I think the end point is slow.

    The issue seems to be related to an HTML or error message being returned rather than the actually data expected.

    I came up with my own patch for the code which seems to work well.

    see attached file engine.js.txt

    Note this fix is hardcoded to only work with the current version

    My approach you will see in engine.js is to look at the version of the url being requested at instead of waiting to get the simple json data back I have just hard coded the json response data - this seems to work and maybe you want to use an appraoch like this as the endpoint being hit in the code is clearly getting bogged down - this approach to fixing the code will also lower the number of requests to the server making it less likely to happen.

    Thank you

  2. dmitryp-rebel commented on Nov 22, 2023

    @dmitryp-rebel

    Also catch same issue continuously:

    Uncaught exception
    SyntaxError: Unexpected token < in JSON at position 0
        at JSON.parse (<anonymous>)
        at IncomingMessage.<anonymous> (C:\bots\bot-amazon-180-1\node_modules\bas-remote-node\src\services\utils.js:14:20)
        at IncomingMessage.emit (node:events:529:35)
        at endReadableNT (node:internal/streams/readable:1368:12)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions