bluesky-social / feed-generator

ATProto Feed Generator Starter Kit
MIT License
919 stars 329 forks source link

fix: handle firehose subscription reconnect on error #46

Closed yuna0x0 closed 1 year ago

yuna0x0 commented 1 year ago

This PR allows the feed generator to try to reconnect back to the firehose subscription endpoint when an error occurred (Eg, WebSocket error 502).

(Close #44)

Review and test process:

  1. Start a WebSocket server which simulates sending 502 error (change the port number as you like):
    
    import { WebSocketServer } from 'ws';

new WebSocketServer({ port: 8080, verifyClient: (_info, callback) => { callback(false, 502); } });



2. Start the WebSocket server on `FEEDGEN_SUBSCRIPTION_ENDPOINT` and confirm that the server doesn't crash.

3. Close the WebSocket server and confirm that the server doesn't crash.

4. Start a real firehose endpoint on `FEEDGEN_SUBSCRIPTION_ENDPOINT` and confirm that the server reconnects.