-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
The Datadog RUM SDK lazy-loads the session replay recorder module using dynamic import(), which causes issues in environments that don't support code splitting or dynamic chunk loading, such as:
- Rails asset pipeline (Sprockets)
- Legacy webpack configurations without
chunkFilenameconfigured - Build systems that require all assets to be declared in a manifest
When session replay is enabled (sessionReplaySampleRate > 0), the SDK attempts to fetch the recorder module at runtime:
GET /assets/startRecording
This results in a 404 error and session replay fails to initialize:
Datadog Browser SDK: Recorder failed to start: an error occurred while initializing the module:
TypeError: Failed to fetch dynamically imported module: https://example.com/assets/startRecording
Requested Feature
Add a configuration option to the datadogRum.init() call that statically bundles the recorder module instead of lazy-loading it:
datadogRum.init({
applicationId: 'xxx',
clientToken: 'xxx',
site: 'datadoghq.com',
service: 'my-app',
sessionReplaySampleRate: 100,
// NEW OPTION:
bundleRecorderModule: true // or lazyLoadRecorder: false
})When this option is enabled, the SDK should:
- Import the recorder module statically at build time
- Skip the dynamic
import()call - Use the bundled recorder directly
Workarounds
Currently, the only workarounds are:
- Disable session replay entirely (
sessionReplaySampleRate: 0) - Suppress console errors (poor UX)
- Migrate to a different build system (significant effort)
Environment
- Browser: All
- SDK Version: @datadog/browser-rum 6.23.0
- Build System: Rails asset pipeline (Sprockets)
- Webpack: 4.x without code splitting configured
Impact
This affects any application using Rails, Django, or other traditional server-rendered frameworks with asset pipelines that don't support dynamic module loading.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request