Skip to content

Bug: Parallel Batch Requests do not return correct order or requestId #1317

@wesbos

Description

@wesbos

Operating System Info

Other

Other OS

Mac OS 15

OBS Studio Version

Other

OBS Studio Version (Other)

31

obs-websocket Version

5.1.0

OBS Studio Log URL

12:02:52.339: [obs-websocket] [WebSocketServer::onOpen] New WebSocket client has connected from [::ffff:127.0.0.1]:59723

OBS Studio Crash Log URL

No response

Expected Behavior

parallel batch requests return data in order of the requests

Current Behavior

CleanShot.2025-09-12.at.12.10.16.mp4

when performing a parallel batch request for GetSourceScreenshot, the data is not returned in order, and optional requestIds are not attached to the correct response data.

I am using the OBS websocket JS package, but this seems to be a lower level problem with the OBS Websocket implementation. I have a list of source names, and I am requesting screenshots of them all:

const sourceNames = ['Desktop', 'cam-only', 'Termina', 'Desk View']; 
            const request: RequestBatchRequest[] = sourceNames.map((sourceName) => ({
              requestType: 'GetSourceScreenshot',
              requestId: sourceName, // This is so we can line them up with the source names in the response
              requestData: {
                sourceName,
                imageFormat: 'png',
                imageWidth: Math.floor(1920 / 8),
                imageHeight: Math.floor(1080 / 8)
              }
            }));
            const previews = await obs.callBatch(request, {
              executionType: 2 // Parallel
            });

I am using parallel execution here, and the order at which the items return are random.

I tried to fix this by attaching a requestId to the request, so I can re-order them once the data comes back, however the requestIds do come back in the correct order, but the responseData attached to it is not the correct source.

If I remove parallel execution, it works correctly.

Steps to Reproduce

see above

Anything else we should know?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions