Challenge - 5 Problems
Deno Deploy Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat happens when you deploy a Deno script with an unhandled promise rejection?
Consider a Deno Deploy script that contains an async function which rejects a promise but does not catch the error. What will be the behavior when this script runs on Deno Deploy?
Deno
addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); }); async function handleRequest(request) { await Promise.reject(new Error('Oops!')); return new Response('Hello World'); }
Attempts:
2 left
💡 Hint
Think about how unhandled promise rejections affect serverless environments.
✗ Incorrect
In Deno Deploy, an unhandled promise rejection inside the request handler causes the script to fail and results in a 500 error response. The runtime does not ignore such errors or retry automatically.
📝 Syntax
intermediateWhich import statement correctly loads a third-party module in Deno Deploy?
You want to import the Oak web framework from a URL in your Deno Deploy project. Which import statement is correct?
Attempts:
2 left
💡 Hint
Deno uses URL imports for third-party modules.
✗ Incorrect
Deno requires full URLs with versioning for third-party modules. Option D correctly imports Oak from deno.land with a version number.
🔧 Debug
advancedWhy does this Deno Deploy script fail to respond?
This script is deployed to Deno Deploy but clients never receive a response. What is the cause?
Deno
addEventListener('fetch', event => { handleRequest(event.request); }); async function handleRequest(request) { return new Response('Hello from Deno Deploy'); }
Attempts:
2 left
💡 Hint
How does Deno Deploy know what to send back to the client?
✗ Incorrect
In Deno Deploy, you must call event.respondWith() with a Response or a promise resolving to a Response. Without it, the request hangs and no response is sent.
❓ lifecycle
advancedHow does Deno Deploy handle environment variables during deployment?
You set environment variables in the Deno Deploy dashboard for your project. When and how are these variables available to your script?
Attempts:
2 left
💡 Hint
Think about how serverless platforms provide secrets and config to running code.
✗ Incorrect
Deno Deploy injects environment variables at runtime. You can access them using Deno.env.get('VAR_NAME') inside your deployed script.
🧠 Conceptual
expertWhat is the effect of using the 'unstable' flag in Deno Deploy scripts?
You deploy a Deno script to Deno Deploy with the --unstable flag enabled. What does this allow you to do?
Attempts:
2 left
💡 Hint
Consider what 'unstable' means in software development.
✗ Incorrect
The --unstable flag in Deno enables access to experimental APIs that are not finalized. This lets developers try new features but with the risk of breaking changes.
