All quizzesHard
Pipeline Internals — Series 3
Preview — 3 of 10 questions
How are the pipes applied across these two arguments?
javascript
@Post(':id')
update(
@Param('id', ParseIntPipe) id: number,
@Body(new ValidationPipe({ whitelist: true })) dto: UpdateCatDto,
) {}AAll pipes from all arguments are collected into one chain applied to the whole request
BThe arguments are processed in parallel, so a failure in one may not prevent the other's pipes from running
CPer argument: each parameter's applicable pipes — global, controller, method, then its own list — are reduced in order over that argument's extracted value, and the arguments are processed in sequence, so the first pipe to throw aborts binding and the handler is never invoked
DOnly the first argument's pipes run; the rest are applied lazily on access
What structure produces the onion behaviour?
javascript
Global → Controller → Route → handlerAThe chain is folded from the innermost outward, each interceptor receiving a CallHandler whose handle() invokes the next layer — and because that invocation is deferred until subscription, nothing executes until the outermost stream is subscribed to
BEach interceptor is invoked in turn and its return value discarded, with the handler called separately at the end
CThe interceptors are pushed onto a stack and popped after the handler completes
DEach interceptor spawns a child execution context, and the results are merged
Why does this filter return a value rather than write a response?
javascript
@Catch(RpcException)
export class RpcFilter implements ExceptionFilter {
catch(exception: RpcException, host: ArgumentsHost) {
return throwError(() => exception.getError());
}
}ABecause RPC filters are executed twice, once to return and once to write
BBecause ArgumentsHost is read-only for non-HTTP transports
CBecause microservice filters must be registered globally
DBecause a non-HTTP context has no response object to write to: the transport's exception context expects the filter to produce the error value it will send back over the wire, so the return value is the response
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.