A. Missing async keyword before handleHeavyTask method
B. @Processor decorator is used incorrectly
C. Job parameter is missing type annotation
D. doHeavyWork should not be awaited
Solution
Step 1: Check method using await
The method handleHeavyTask uses 'await' but is not marked async, which causes a syntax error.
Step 2: Confirm correct fix
Adding 'async' before the method fixes the error, allowing await to work properly.
Final Answer:
Missing async keyword before handleHeavyTask method -> Option A
Quick Check:
await needs async method [OK]
Hint: Use async before methods that await promises [OK]
Common Mistakes:
Ignoring async keyword with await
Thinking @Processor is wrong here
Assuming doHeavyWork can't be awaited
5. You want to process image uploads in the background to avoid slowing down user requests. Which approach best uses NestJS background processing to achieve this?
hard
A. Create a @Processor class with a @Process method that resizes images asynchronously
B. Resize images directly inside the controller handling uploads
C. Use @Controller with @Get to process images synchronously
D. Run image processing code in the main thread without decorators
Solution
Step 1: Identify background processing use case
Image resizing is a heavy task that can slow down user requests if done synchronously.