azure-functions-node-worker
Skill110 starsChanged 3 years agoMITView on GitHub
Repository-specific Azure Functions Node.js Host-worker architecture and change-validation workflow. Use for every implementation, fix, refactor, test, or explanation involving this repository, especially worker startup, gRPC StreamingMessage handling, initialization, specialization, metadata/indexing, function loading and invocation, programming models, hooks, converters, logging, process lifecycle, Node.js behavior, protobuf, build, or tests. Validate each code change against Host compatibility and Node runtime invariants.
- Reads credentials
In this repository2 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 10 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 11
Read architecture.md before reasoning about behavior that crosses the Host-worker boundary or more than one lifecycle stage.
- Very specific: line 15
Treat this repository as the process boundary between the Azure Functions Host and a user's Node.js function application:
- Very specific: line 42
If any critical path is affected, also load azure-functions-node-worker-critical-path.
- Distinctive: line 46
Start at the code that directly decides behavior.
- Very specific: line 56
Every handled request retains its requestId, expected response property, and StatusResult semantics.
- Distinctive: line 71
Keep the change at the owning abstraction.
- Distinctive: line 73
Use the test map in architecture.md.
- Very specific: line 90
Run npm run host-sanity for changes to startup arguments, gRPC behavior, protocol routing, worker configuration, module loading, or Host …
- Distinctive: line 94
Do not say a change is validated without executable evidence.
- Distinctive: line 102
Do not treat lint, compilation, snapshots, or generated-code verification alone as behavioral validation.
- Distinctive: line 121
Do not infer Azure Functions Host behavior solely from worker code.
- Distinctive: line 122
Do not "fix" intentional execution of function app code as though it were arbitrary code execution.
- Distinctive: line 123
Do not hand-edit generated protobuf outputs.
- Very specific: line 124
Do not silently broaden supported Node.js versions, protocol fields, capabilities, or programming-model behavior.
- Distinctive: line 125
Do not claim approval for a critical-path change.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Azure Functions Node.js Worker
Apply this skill to code changes in this repository. It supplies domain context and a mandatory validation workflow; it does not replace focused security analysis or required human review.
Read architecture.md before reasoning about behavior that crosses the Host-worker boundary or more than one lifecycle stage.
Core Model
Treat this repository as the process boundary between the Azure Functions Host and a user's Node.js function application:
src/nodejsWorker.tsenters the worker andsrc/Worker.tsparses Host-provided startup arguments.src/GrpcClient.tscreates the bidirectional gRPC stream.src/setupEventStream.tsroutes HostStreamingMessagerequests to event handlers and constructs protocol responses.- Initialization or specialization loads the function app and establishes process-wide state in
WorkerContextandAppContext. - Metadata/load handlers select worker indexing or legacy Host indexing.
InvocationHandlerbridges RPC data to the active@azure/functionsprogramming model, runs hooks, invokes user code, and converts the response.- Termination runs app hooks, closes the stream, and exits the process.
The Host, worker, programming model, and function app are separate compatibility surfaces. Do not reason about one in isolation when a change crosses their boundary.
Required Workflow
1. Classify the Change
Identify all affected surfaces before editing:
- Host RPC contract or message routing
- worker startup, state, or lifecycle
- function app discovery or module loading
- programming model or core API bridge
- invocation bindings or typed-data conversion
- hooks, logging, errors, or diagnostics
- Node.js runtime, event loop, environment, working directory, or process exit
- generated protobuf, packaging, dependencies, or release configuration
If any critical path is affected, also load azure-functions-node-worker-critical-path. If data crosses a trust boundary, executable content is loaded, credentials may be exposed, or dependencies change, also load azure-functions-node-worker-security.
2. Trace the Owning Path
Start at the code that directly decides behavior. Trace only the relevant path:
Host input -> StreamingMessage -> handler -> worker/app state or programming model -> response/log/side effect
State the local invariant being preserved and a cheap test that could falsify the proposed behavior. Do not edit generated rpc.js, rpc_static.js, or rpc.d.ts directly. Protocol changes start in azure-functions-language-worker-protobuf/src/proto/ and regenerate outputs with npm run gen.
3. Preserve Domain Invariants
For every change, verify the applicable invariants:
- Every handled request retains its
requestId, expected response property, andStatusResultsemantics. - Handler failures are returned through the common event-stream error path; host-bound error text remains sanitized.
setupEventStream()andsetupCoreModule()are established before user app code depends on them.- Worker state is process-wide. Specialization resets app state without accidentally reinitializing the worker identity or stream.
- Worker indexing and legacy Host indexing remain distinct; registration locks are not weakened.
- Invocation input/output conversion remains symmetric with the programming-model contract.
- Pre- and post-invocation hooks retain ordering and documented mutation behavior.
- User code loading preserves CommonJS and ESM behavior, package
mainhandling, retry behavior, and entry-point error policy. - Code does not assume gRPC requests or invocations are serialized. Avoid blocking the Node.js event loop and unbounded synchronous work.
- Changes to
process.env,process.cwd(), module caches, listeners, timers, and process exit account for process-wide effects and test cleanup. - Logs keep system/user category semantics and do not bypass error or secret sanitization.
- Generated protocol outputs match their
.protosources and are reviewed as generated artifacts.
4. Implement and Test the Behavior
Keep the change at the owning abstraction. Add or update the nearest test that observes the externally meaningful result, not only an internal call.
Use the test map in architecture.md. Prefer the smallest executable check first, for example:
npx mocha -r ts-node/register "test/Worker.test.ts"
npx mocha -r ts-node/register "test/eventHandlers/InvocationHandler.test.ts"Then run the checks required by the affected surface:
npm run lint
npm test
npm run buildnpm run build regenerates protobuf outputs before compiling. Inspect those generated changes and do not accept unrelated churn.
Run npm run host-sanity for changes to startup arguments, gRPC behavior, protocol routing, worker configuration, module loading, or Host compatibility when the adjacent Host repository and prerequisites are available. Report clearly when that integration check cannot run.
5. Report Validation
Do not say a change is validated without executable evidence. Report:
- the invariant tested
- the exact focused and broad checks run
- pass/fail results
- checks not run and why
- whether security analysis or human review is required
Do not treat lint, compilation, snapshots, or generated-code verification alone as behavioral validation.
Change-to-Validation Matrix
| Changed surface | Minimum focused validation | Broader validation |
Worker.ts, GrpcClient.ts, startup | test/Worker.test.ts, test/GrpcClient.test.ts as applicable | lint, full tests, build; Host sanity for contract changes |
setupEventStream.ts, event handlers | matching test/eventHandlers/*.test.ts | lint, full tests, build |
startApp.ts, package parsing, script loading | test/startApp.test.ts, test/parsers/parsePackageJson.test.ts, or test/loadScriptFile.test.ts | lint, full tests, build |
| invocation, hooks, converters | test/eventHandlers/InvocationHandler.test.ts plus a focused regression | lint, full tests, build |
| reload or process state | test/eventHandlers/FunctionEnvironmentReloadHandler.test.ts with state cleanup assertions | lint, full tests, build |
| termination | test/eventHandlers/terminateWorker.test.ts | lint, full tests, build |
| errors, logging, sanitization | test/errors.test.ts or nearest handler test | lint, full tests, build; security skill |
| blocked event loop or runtime versions | test/blockMonitorTest.ts or test/utils.test.ts | lint, full tests, build |
.proto or generated RPC files | regenerate with npm run gen, focused handler/converter tests | lint, full tests, build, generated diff review, Host sanity |
| dependency, bundle, or packaging files | focused startup/load test | lint, full tests, build, webpack; security and human review |
Boundaries
- Do not infer Azure Functions Host behavior solely from worker code. If compatibility depends on unspecified Host behavior, identify the assumption and require Host documentation, Host source, or an integration test.
- Do not "fix" intentional execution of function app code as though it were arbitrary code execution. The worker exists to load and run that code; security findings must show an unintended boundary expansion.
- Do not hand-edit generated protobuf outputs.
- Do not silently broaden supported Node.js versions, protocol fields, capabilities, or programming-model behavior.
- Do not claim approval for a critical-path change. Produce validation evidence and hand it to the required human reviewer.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

