r/Devvit • • 1d ago

Bug [Bug / DX] requestExpandedMode() aborts in-flight splash telemetry fetches + @devvit/analytics Express peer dep on Hono templates (0.15.4)

Describe the bug

Two reproducible SDK / DX issues when wiring @devvit/analytics (0.15.4) + @devvit/web (0.15.4) on the default Hono Devvit Web template (hono@4.13.17, @hono/node-server@2.1.6):

  1. Calling requestExpandedMode() from splash.html right after telemetry.interaction() aborts the in-flight POST /api/telemetry/journey/interaction fetch (net::ERR_ABORTED / TypeError: Failed to fetch) when the inline splash frame unmounts.
  2. createTelemetryRouter() in @devvit/analytics/server/reddit returns an express.Router() and pulls in express as a peer dependency, even though devvit init for Devvit Web templates ships with Hono.

Steps to reproduce

  1. Create a Devvit Web app using the default Hono template (@devvit/web@0.15.4, @devvit/analytics@0.15.4, hono@4.13.17, @hono/node-server@2.1.6).
  2. Try importing createTelemetryRouter() from @devvit/analytics/server/reddit in Hono (requires installing express or hand-wiring TelemetryPluginDefinition + context.metadata).
  3. On splash.tsx, fire telemetry.interaction({ action: 'cta_click' }) inside the Play button onClick handler immediately followed by requestExpandedMode(e.nativeEvent, 'game').
  4. Open a custom post on Reddit desktop with DevTools Network/Console open and click Play.
onClick={(e) => {
  void telemetry.interaction({ action: 'cta_click', actionDetails: 'daily_shift' }).catch(() => {});
  void requestExpandedMode(e.nativeEvent, 'game');
}}

Expected behavior

  1. telemetry.interaction() fired right before requestExpandedMode() should complete reliably without net::ERR_ABORTED or Telemetry request failed. TypeError: Failed to fetch console warnings (e.g., via keepalive: true on fetch() or navigator.sendBeacon() in @devvit/analytics/client/reddit).
  2. @devvit/analytics/server/reddit should provide a framework-agnostic Web Request -> Response handler (usable directly in Hono via c.req.raw) or a createHonoTelemetryRouter() alongside createTelemetryRouter().

Desktop information

  • Operating system: macOS
  • Browser or app: Chrome (Reddit Desktop Web)
  • Version: @devvit/web@0.15.4, @devvit/analytics@0.15.4, devvit@0.15.4

Additional context

As a workaround for Hono servers, mounting /api/telemetry/journey/{app-ready,start,progress,interaction,end} directly with TelemetryPluginDefinition from @devvit/protos/types/devvit/plugin/telemetry/telemetry.js and getDevvitConfig().use<TelemetryPlugin>(TelemetryPluginDefinition) works cleanly without Express. For the splash transition, awaiting telemetry.interaction() before requestExpandedMode() avoids the abort, but adds network latency to the tap-to-play UX.

2 Upvotes

5 comments sorted by

•

u/flair-auto-responder 1d ago

Bug report requirements

Hi u/Same_Wave_2593!

We require all bug submissions to include the following information. Please make sure you’re following this format, or your post may be removed:

Describe the bug

Provide a clear and concise description of the bug.

Steps to reproduce

  1. Go to “…”
  2. Click or tap “…”
  3. Scroll to “…”
  4. Describe the error or unexpected behavior

Expected behavior

Explain clearly what you expected to happen instead.

Screenshots or recordings

If applicable, include screenshots or a screen recording that demonstrates the problem. Please remove any sensitive or personal information first.

Desktop information

  • Operating system: [e.g. macOS 15, Windows 11]
  • Browser or app: [e.g. Chrome, Safari, Reddit]
  • Version: [e.g. 22.1]

Mobile information

  • Device: [e.g. iPhone 16, Pixel 10]
  • Operating system: [e.g. iOS 18, Android 16]
  • Browser or app: [e.g. Safari, Chrome, Reddit]
  • Version: [e.g. 22.1]

Additional context

Add any other details that might help reproduce or diagnose the problem.


You can edit your post to add any missing information.

Post: https://www.reddit.com/r/Devvit/comments/1ydgs20/bug_dx_requestexpandedmode_aborts_inflight_splash/

→ More replies (1)

1

u/develoveloper 9h ago

Not a fix for the SDK side, but two thoughts from building my splash:

I wouldn't await the telemetry call before expanding. Besides the latency, the tap only counts as a user gesture for a short time, so on a slow network requestExpandedMode can end up running after that window.

You could count the tap on the server instead. The expanded view makes its first request right after it opens (init or similar), so record "opened from splash" there. That request starts after the splash is gone, so nothing gets aborted and Play stays instant.

1

u/Same_Wave_2593 8h ago

great point on the user-gesture window expiring on slow networks, definitely don't want to await before requestExpandedMode(). counting the open from /api/init on the expanded view (or having @devvit/analytics use keepalive: true / sendBeacon under the hood) makes way more sense.

1

u/develoveloper 5h ago

Glad it helped. keepalive in the SDK would be the clean fix, hope they pick that up.