Bỏ qua, đến nội dung

Request lifecycle

Trang này gom các chuỗi thực thi đầy đủ - từ user action hoặc lệnh vận hành xuống database / realtime - phục vụ debug runtime và đối chiếu với log. Nối tiếp Server architectureSecurity model.


1) Read flow - đọc dữ liệu

User mở màn hình list/detail → client gọi API → server đi qua data source → resource → auth/ACL → repository → DB.

Debug tips:

  • Sai collection / sai data → kiểm tra header x-data-source và mapping collection.
  • Thiếu record → kiểm tra FilterParser, fixed params (ACL), filter phía client.

2) Write flow - ghi dữ liệu

Ghi qua POST / PUT / PATCH / DELETE. Chuỗi: chuẩn hóa params (pre-action) → ACL → repository → transaction → hooks.

Debug tips:

  • 403 sau khi params đúng → kiểm tra ACL snippet, fixed params, role config.
  • Validation error → xem pre-action, schema template.
  • Side effect không chạy → kiểm tra model hooks (beforeCreate, afterUpdate).

3) WebSocket - realtime

Client duy trì kết nối WebSocket để nhận trạng thái maintaining, thông báo, hoặc sự kiện refresh.

Debug tips:

  • UI "đơ" hoặc không đồng bộ → kiểm tra kênh WS, payload auth, handler maintaining/refresh phía client.

4) Install flow - cài đặt mới


5) Upgrade flow - nâng cấp

Thứ tự: core migration trước → plugin migration (theo dependency) → ghi version → restart.


6) Enable plugin flow


7) Data plane vs Control plane

PlaneKhi nàoVí dụ
Data planeMỗi request userGET /api/users:list, POST /api/orders:create
Control planeCài đặt, nâng cấp, bật/tắt pluginapp install, app upgrade, enable plugin trong admin

Lỗi lúc request → data plane (middleware, action, repository). Lỗi lúc khởi động / cài đặt → control plane (lifecycle, migration).


8) Debug checklist

Triệu chứngHướng xem đầu tiên
Sai data source / sai collectionDataSourceManager, header x-data-source, mapping collection ↔ resource
401 UnauthorizedAuthManager, bearer token, authenticator config
403 ForbiddenACL: role config, snippet, fixed params, availableActions
Query sai dữ liệu / thiếu recordFilterParser, OptionsParser, pre-action, filter phía client, fixed params
Ghi thất bạiPre-action validate, ACL write permission, transaction, model hooks
UI không phản ánh trạng tháiWebSocket: maintaining, refresh, reconnect
Plugin mới không hiệu lựcLifecycle: beforeLoadloadinstall / upgradeenable
Migration failThứ tự: core migration trước plugin; kiểm tra dependency giữa plugins
Remote plugin client không loadAPI pm:listEnabled, network khi tải bundle, getPlugins() / add()

Đọc tiếp