cloudflare / cloudflare/workers-sdk
🐛 BUG: console.assert() is evaulated but does nothing when an assertion fails
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 187
Description
### Which Cloudflare product(s) does this pertain to?
Workers Runtime
### What version(s) of the tool(s) are you using?
Wrangler 3.22.1
### What version of Node are you using?
Node 18.9.0
### What operating system are you using?
Linux
### Describe the Bug
Assertions have the potential for preventing critical conditions from occurring. Especially for things like business logic they are an invaluable tool for the development of correct systems. But in the Workers runtime the following code:
```
...
console.assert( typeof( 5 ) == 'string', 'This should display as 5 is NOT a string!' )
return 'Success!'
}
```
Does not halt execution. The condition is actually evaluated, but on failure **no error** is thrown, **no message** reaches the logs and execution _continues_. Eeek! This behaviour is NOT what happens in a browser on a failed assertion.
Thank you for your efforts.
We :orange_heart: Cloudflare Workers!
### Please provide a link to a minimal reproduction
_No response_
### Please provide any relevant error logs
_No response_
Contributor guide
Research direction
Start by reproducing the provided console.assert() example in the Workers Runtime with Wrangler 3.22.1 on Node 18.9.0 and Linux. No minimal reproduction, error logs, or source file is provided, so identify the runtime path handling console.assert and verify that a failed assertion logs an error or halts execution rather than continuing silently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100