Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#10,794 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, mongodb, nodejs, postgres
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu từ src/LiveQuery/ParseLiveQueryServer.ts quanh dòng 1136, nơi _handleSubscribe gọi parseQuery.withJSON(request.query), và so sánh với việc chuẩn hóa keys và watch quanh các dòng 1370-1373. withJSON của SDK trong ParseQuery.js (dòng 451 và 457) gọi .split(','), vì vậy cách sửa là chuẩn hóa các mảng thành chuỗi phân tách bằng dấu phẩy hoặc đặt trực tiếp _select/_watch. Hoàn thành khi một subscription dùng select() hoặc watch() thành công với trigger beforeSubscribe đã đăng ký, cho cả MongoDB và Postgres.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
JavaScript
Star
21.4k
Fork
4.8k
Merge trung bình
5 giờ 8 phút
Pull request đã merge (30 ngày)
87

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của parse-community/parse-server

Tất cả issue của parse-community/parse-server

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.