-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Currently, the rocketUrlParser in the AfterSaveOEmbed hook processes message URLs sequentially using a for await...of loop. When a user sends a single message containing multiple external URLs, the server halts and waits for each parseUrl() HTTP request to completely resolve before initiating the next one.This creates an
Steps to reproduce:
- Boot up a local Rocket.Chat development server.
- Ensure OEmbed/Link Previews are enabled in Administration -> Settings -> Message.
- Send a single message in any channel containing 4 or 5 different external URLs (e.g., various news articles or YouTube links).
- Trace the server execution logs or observe the response time. The URLs are fetched one after the other, causing a noticeable delay in processing the final message state.
Expected behavior:
The server should initiate the OEmbed HTTP requests for all valid URLs in the message array concurrently, drastically reducing the total time spent in the rocketUrlParser hook.
Actual behavior:
The server waits for parseUrl(item.url) to completely finish before starting the network request for the next URL in the array, creating a sequential blocking queue.
Server Setup Information:
- Version of Rocket.Chat Server: develop branch (Latest)
- License Type: Community
- Number of Users: Local Dev (1)
- Operating System: Linux/WSL
- Deployment Method: Local Development
- Number of Running Instances: 1
- DB Replicaset Oplog: Enabled
- NodeJS Version: 22.16.0
- MongoDB Version: 8.2.4
Client Setup Information
Desktop App or Browser Version: Chrome/Brave (Latest)
Operating System: Windows / Linux
Additional context
Target File: apps/meteor/app/lib/server/functions/hooks/AfterSaveOEmbed.ts
Target Function: rocketUrlParserI