Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

LiveQuery subscription with select() or watch() fails when a beforeSubscribe trigger exists

Aperta Adatta ai principianti
#10,794 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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
Ambito
api, backend

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 keys and watch as arrays of strings (src/LiveQuery/RequestSchema.js:65-71 and :111-117), and the JS SDK's LiveQuery client sends them as arrays.
  • When a beforeSubscribe trigger exists, _handleSubscribe rebuilds an SDK query from the raw subscribe request: parseQuery.withJSON(request.query) (src/LiveQuery/ParseLiveQueryServer.ts:1136).
  • The SDK's withJSON expects these fields to be comma-separated strings: this._select = json.keys.split(',') and this._watch = json.watch.split(',') (ParseQuery.js:457 and :451). Calling .split() on an array throws a TypeError, 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
  1. Start Parse Server with LiveQuery enabled for class Item.
  2. Register a beforeSubscribe trigger, even an empty one:
    Parse.Cloud.beforeSubscribe('Item', () => {});
    
  3. 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 with Postgres)
  • 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di parse-community/parse-server

Tutte le issue di parse-community/parse-server

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.