LiveQuery subscription with select() or watch() fails when a beforeSubscribe trigger exists
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, mongodb, nodejs, postgres
Direzione di ricerca
Inizia da src/LiveQuery/ParseLiveQueryServer.ts intorno alla riga 1136, dove _handleSubscribe chiama parseQuery.withJSON(request.query), e confrontalo con la normalizzazione di keys e watch intorno alle righe 1370-1373. Il withJSON dell'SDK in ParseQuery.js (righe 451 e 457) chiama .split(','), quindi la correzione consiste nel normalizzare gli array in stringhe separate da virgole oppure nell'impostare direttamente _select/_watch. È completato quando una subscription con select() o watch() va a buon fine con un trigger beforeSubscribe registrato, sia per MongoDB sia per Postgres.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Issue Description
When a beforeSubscribe trigger is registered for a class, a LiveQuery subscription to that class fails if the client query uses select() or watch(). The subscription is rejected with error code 141 and the message json.keys.split is not a function (or json.watch.split is not a function for watch()).
The cause is a mismatch between the LiveQuery protocol and the JS SDK query deserializer:
- The LiveQuery request schema defines
keysandwatchas arrays of strings (src/LiveQuery/RequestSchema.js:65-71and:111-117), and the JS SDK's LiveQuery client sends them as arrays. - When a
beforeSubscribetrigger exists,_handleSubscriberebuilds an SDK query from the raw subscribe request:parseQuery.withJSON(request.query)(src/LiveQuery/ParseLiveQueryServer.ts:1136). - The SDK's
withJSONexpects these fields to be comma-separated strings:this._select = json.keys.split(',')andthis._watch = json.watch.split(',')(ParseQuery.js:457and:451). Calling.split()on an array throws aTypeError, which is reported to the client as error 141.
Both shapes are already handled elsewhere in the same file, when the subscription info is stored:
if (request.query.keys) {
subscriptionInfo.keys = Array.isArray(request.query.keys)
? request.query.keys
: request.query.keys.split(',');
}
(src/LiveQuery/ParseLiveQueryServer.ts:1370-1373)
So normalizing keys and watch the same way before calling withJSON — or assigning _select/_watch directly — would make the two paths consistent.
The combination is only broken when both parts are used together: without a beforeSubscribe trigger, select() and watch() subscriptions work, and with the trigger a subscription without select()/watch() works.
Steps to reproduce
- Start Parse Server with LiveQuery enabled for class
Item. - Register a
beforeSubscribetrigger, even an empty one:Parse.Cloud.beforeSubscribe('Item', () => {}); - Subscribe from a client with a field selection:
const query = new Parse.Query('Item').select('name'); const subscription = await query.subscribe();
Actual Outcome
The subscription fails with error code 141 and the message json.keys.split is not a function. Using watch('name') instead of select('name') fails the same way with json.watch.split is not a function.
Expected Outcome
The subscription succeeds, and the trigger receives the query, as it does when no beforeSubscribe trigger is registered.
Environment
Server
- Parse Server version:
9.10.5-alpha.11 - Operating system:
macOS (Darwin 24.6.0) - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
MongoDB(also reproduced withPostgres) - Database version:
8.0.4(Postgres 16 / PostGIS 3.5) - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
JavaScript - SDK version:
8.6.2
Logs
code=141 json.keys.split is not a function
code=141 json.watch.split is not a function
- Lingua principale
- JavaScript
- Stelle
- 21.4k
- Fork
- 4.8k
- Merge medio
- 5h 8m
- PR unite (30g)
- 87
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di parse-community/parse-server
-
Query with an include path through an inherited object member fails with an internal server errorForse già presa @charan-rathore l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
parse-community/parse-server#10795 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add MongoDB 9 supportForse già presa @ga262 l’ha presa 15 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
parse-community/parse-server#10750 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
parse-community/parse-server#10720 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
parse-community/parse-server#10710 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Node.js version in `.nvmrc` does not satisfy `engines.node`Forse già presa @kokokoXUY l’ha presa 24 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
parse-community/parse-server#10699 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di parse-community/parse-server
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
module-federation/core#5205 ·
I maintainer di solito rispondono entro 1 giorno
-
affects:v0.5.2 area:frontend audit:ui-ux-2026-10 bug priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
berntpopp/kidney-genetics-db#326 ·
I maintainer di solito rispondono entro 1 giorno
-
task
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
TAMULib/fw-registry#550 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
-
NWCWalletService.subscribe: response is never published if the handler finishes after unsubscribe (regression in 8.1.0)Forse già presa @ajaysehwal l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100