LiveQuery subscription with select() or watch() fails when a beforeSubscribe trigger exists
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
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
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
- 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
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của parse-community/parse-server
-
Query with an include path through an inherited object member fails with an internal server errorCó thể đã có người làm @charan-rathore đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
parse-community/parse-server#10795 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add MongoDB 9 supportCó thể đã có người làm @ga262 đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
parse-community/parse-server#10750 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
parse-community/parse-server#10720 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
parse-community/parse-server#10710 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Node.js version in `.nvmrc` does not satisfy `engines.node`Có thể đã có người làm @kokokoXUY đã nhận 24 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
parse-community/parse-server#10699 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của parse-community/parse-server
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
fix(套件): test_bundle 往仓库的 preset/skills 写哨兵,并发跑的 test_installer 拷贝时撞 ENOENT(CI 红)Có thể đã có người làm @Miaotofu01 đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Miaotofu01/Study-Mate#216 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
beginner-friendly category:fixtures community enhancement first-timers-only good first issue hacktoberfest help wanted low hanging fruit micro-contribution type: task up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Berserk-hub150/skillhawk#229 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 8 ngày