Ending a script block with a comment line errors out
See original GitHub issueNot a problem in real life scenarios but ending a script block with a comment terminates the script’s execution with a fatal error.
Example
### Health check
{{BASE_URL}}/checks/health
{{
console.log('I will be outputted')
// I have a feeling this will not end well
}}
prompt$ httpyac --env prod --all ./requests/system/health-check.http
js: console.log('I will be outputted')
// I have a feeling this will not end well
SyntaxError: Unexpected end of input
at new Script (vm.js:101:7)
at createScript (vm.js:262:10)
at Object.runInThisContext (vm.js:310:10)
at /Users/me/.nvm/versions/node/v14.15.5/lib/node_modules/httpyac/dist/index.js:1:37428
at Generator.next (<anonymous>)
at /Users/me/.nvm/versions/node/v14.15.5/lib/node_modules/httpyac/dist/index.js:1:36507
at new Promise (<anonymous>)
at s (/Users/me/.nvm/versions/node/v14.15.5/lib/node_modules/httpyac/dist/index.js:1:36252)
at g (/Users/me/.nvm/versions/node/v14.15.5/lib/node_modules/httpyac/dist/index.js:1:36786)
at t.JavascriptAction.<anonymous> (/Users/me/.nvm/versions/node/v14.15.5/lib/node_modules/httpyac/dist/index.js:1:38658)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Block comments in user script not working properly [19377]
Block comments are useful for both temporarily commenting out a contiguous series of lines as well as easily removing the block comment. However ......
Read more >Stop or exit a PowerShell script when it errors - 4sysops
One way a scripter can invoke a terminating error is by using the throw keyword. This PowerShell construct creates a terminating error while ......
Read more >Handle errors in ScriptBlock in Invoke-Command Cmdlet
When there is an error while executing New-Service the $errortext ErrorVariable get set properly inside the ScriptBlock, because the text: " ...
Read more >Comments at the end of script lines | Automic Workload ...
I recently came across an object with comments at the end of script lines. E.g.,. :SET &VAR1# = "ABC123" ! This is a...
Read more >Everything you wanted to know about exceptions - PowerShell
Basic terminology; Basic command syntax; $PSItem; Working with exceptions; Try can create terminating errors; Trap; Closing remarks.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Since I’m a fan of GitLens, I often leave out comments like this.
But you’re right, a comment would make sense here, since there are two little surprises in those two lines
With the latest update (v2.20.0) the issue is fixed