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

Various Fixes: Websocket heartbeat, historical request sorting, et al #400

Merged
merged 23 commits into from
Dec 11, 2024

Conversation

brettimus
Copy link
Contributor

@brettimus brettimus commented Dec 9, 2024

TODOs

  • Refactor loadHistoricalRequest
  • Document telegram bot example
  • Fix ordering of history
  • Update changelog
  • Update package.json

Description

This PR does a few things:

  • Adds proper pong responses for the heartbeat coming from the Studio frontend
  • Fix an edge case where request bodies were not loaded from history into the UI
  • Fix sorting of historical requests (partially)
  • Fix default timestamps in our sqlite database to be iso-8601
  • Adds a minimal telegram bot example to the monorepo

Heartbeat

Our pong responses to ping messages were never being sent down the wire, which caused the useRealtimeService hook to think that the websocket connection was no longer open after a minute.

Changing the studio api's websocket server to treat pings as regular messages resolved the issue.

I kept the old code as a comment with an explainer that it was not working properly.

Load request bodies from historical requests

When poking around with the new example api, I hit a case where loadHistoricalRequest was not setting the body for certain requests from the history. I had to make an ugly function uglier, but resolve this issue by copy-pasting code ((working on a refactor now))

NOTE This will still be broken when we have a trace but the request was not proxied through Studio API (via the UI or Webhonc)

Fix Default Studio Api Database Timestamps

CURRENT_TIMESTAMP in sqlite was not iso8601. Changed the db schema default values to fix that, since sometimes we were adding iso timestamps manually to certain records, and then having a mix of timestamps messed up sorting in the UI

New Example: Telegram bot

Why?

I wanted a webhook related example in our monorepo to test possible connection interruptions to webhonc.

Copy link

pkg-pr-new bot commented Dec 9, 2024

Open in Stackblitz

npm i https://pkg.pr.new/fiberplane/fpx/@fiberplane/studio@400
npm i https://pkg.pr.new/fiberplane/fpx/@fiberplane/hono-otel@400

commit: 5c67a16

@brettimus brettimus force-pushed the various-websocket-fixes branch 2 times, most recently from a1669ed to f85b0f2 Compare December 10, 2024 15:28
@@ -194,6 +194,19 @@ export function useRequestorHistory() {
})),
),
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function badly needs a refactor, but i have other things to do this week 😬

@brettimus brettimus marked this pull request as ready for review December 10, 2024 17:44
@brettimus brettimus changed the title Various websocket fixes Various Fixes: Websocket heartbeat, historical request sorting, et al Dec 10, 2024
@brettimus brettimus force-pushed the various-websocket-fixes branch from aa33804 to 5c67a16 Compare December 11, 2024 12:51
@brettimus brettimus merged commit 43684e9 into main Dec 11, 2024
4 checks passed
@brettimus brettimus deleted the various-websocket-fixes branch December 11, 2024 13:00
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

Successfully merging this pull request may close these issues.

3 participants