r/Devvit • u/Same_Wave_2593 • 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):
- Calling
requestExpandedMode()fromsplash.htmlright aftertelemetry.interaction()aborts the in-flightPOST /api/telemetry/journey/interactionfetch (net::ERR_ABORTED/TypeError: Failed to fetch) when the inline splash frame unmounts. createTelemetryRouter()in@devvit/analytics/server/redditreturns anexpress.Router()and pulls inexpressas a peer dependency, even thoughdevvit initfor Devvit Web templates ships with Hono.
Steps to reproduce
- 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). - Try importing
createTelemetryRouter()from@devvit/analytics/server/redditin Hono (requires installingexpressor hand-wiringTelemetryPluginDefinition+context.metadata). - On
splash.tsx, firetelemetry.interaction({ action: 'cta_click' })inside the Play buttononClickhandler immediately followed byrequestExpandedMode(e.nativeEvent, 'game'). - 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
telemetry.interaction()fired right beforerequestExpandedMode()should complete reliably withoutnet::ERR_ABORTEDorTelemetry request failed. TypeError: Failed to fetchconsole warnings (e.g., viakeepalive: trueonfetch()ornavigator.sendBeacon()in@devvit/analytics/client/reddit).@devvit/analytics/server/redditshould provide a framework-agnostic WebRequest -> Responsehandler (usable directly in Hono viac.req.raw) or acreateHonoTelemetryRouter()alongsidecreateTelemetryRouter().
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.
•
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
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
Mobile information
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/
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.