Frontend Development 19 min read

TaskHub: Frontend Automation Platform and RPC BFF Design Practices

TaskHub is a front‑end automation platform that separates core and auxiliary modules to improve task scheduling, logging, and debugging, featuring a decoupled engine, RPC BFF architecture, and real‑world use cases that demonstrate faster issue resolution, task termination, and overall development efficiency.

Ctrip Technology
Ctrip Technology
Ctrip Technology
TaskHub: Frontend Automation Platform and RPC BFF Design Practices

Introduction – The article defines automation as replacing manual operations with code to free labor and boost efficiency, and highlights common pain points such as high maintenance cost, low success rate, and difficult troubleshooting in front‑end automation tasks.

Platform Background – Multiple teams at Ctrip have built automation projects that share problems: inability to stop tasks promptly, low fault‑diagnosis efficiency, unstructured logs, difficulty reproducing issues, and unrestricted log access.

Platform Goals – To address these common issues, the platform aims to (1) improve fault‑diagnosis speed through detailed logs and auxiliary tools, (2) provide passive task‑exception awareness via real‑time monitoring, and (3) let developers focus on core business logic by ensuring stable, high‑performance task execution.

TaskHub Overview – TaskHub splits automation into two parts: the Platform for recording and managing task artifacts, and the Engine for executing tasks. The platform offers three modules – Project , Task , and Log – with strict permission checks. Logs are divided into business and system logs and can include images.

Engine Design – The engine is distributed as an NPM package and runs as a separate Node subprocess for each task. Benefits include data isolation, easy cleanup via process.exit() , and remote task termination. Initialization uses the SDK’s engine object and engine.initProject to bind a project ID. Tasks are started with engine.addTask .

The engine creates a new subprocess for each task and establishes a bidirectional communication channel with the main process. The main process registers listeners on a task instance to receive status updates, while the task script can send messages back. This mechanism supports real‑time status monitoring, task control (pause/resume/terminate), exception handling, and data transfer.

Engine‑Platform Communication – Communication is defined by the IMessageSender interface, allowing any implementation to plug into the engine. When the platform is unavailable, the engine falls back to a basic logging solution, ensuring task execution continues.

Use Cases

1. Vacation Business Data Entry – Automating periodic data entry reduced manual effort but introduced new challenges: low debugging efficiency and inability to stop individual tasks. After integrating TaskHub, tasks could be terminated instantly, and log‑based troubleshooting became much faster.

2. Complex Business Scenario Automation – A two‑step workflow (fetch data from one site, then conditionally input data on another) was split into separate tasks. TaskHub provided proactive exception notifications, snapshot‑based error logs, and clear downstream‑upstream log linking, dramatically simplifying fault isolation.

TaskHub now runs 12 automation projects, executing over 480,000 tasks and storing more than 13 million log entries.

RPC BFF Best Practices

When selecting a technology stack for the TaskHub BFF, RPC BFF was chosen for its low onboarding cost and strong consistency across multiple consumers. Traditional RPC services require separate documentation, whereas RPC BFF lets consumers obtain interface definitions and call functions with a single command.

6.1 Convergence Types – Instead of returning separate success/failure codes, RPC BFF uses a union type to represent all possible outcomes, eliminating duplicated error‑code maintenance and ensuring exhaustive handling via the type system.

6.2 Atomic Process – RPC BFF treats functions as atomic processes. By decomposing services into smallest indivisible units, they can be composed into directed acyclic graphs. Example: a getProjectById function returns project data or a not‑found error; higher‑level logic calls getProjectSetting as a normal function, benefiting from clear types and reuse.

Conclusion – By reorganizing automation into core and auxiliary modules, introducing a decoupled engine with bidirectional communication, and applying RPC BFF principles, TaskHub improves automation reliability, debugging speed, and overall development efficiency while keeping the original project design unchanged.

typescripttask schedulingloggingnodejsfrontend automationrpc bff
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.