Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async/await examples in docs don’t run #219

Closed
Ivo-Balbaert opened this issue Jul 4, 2021 · 3 comments
Closed

Async/await examples in docs don’t run #219

Ivo-Balbaert opened this issue Jul 4, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Ivo-Balbaert
Copy link
Contributor

Ivo-Balbaert commented Jul 4, 2021

Describe the bug
All examples in async/await have either runtime or compilation issues:

Example 1: Windows 10:
 error: 
(node:8404) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined
     at D:\Clio\own_projects\await1\build\main.clio.js:1:187
-- at run (D:\Clio\own_projects\await\build\node\node_modules\clio-run\src\index.js:106:26)
-- at async D:\Clio\own_projects\await\build\node\node_modules\clio-run\src\runners\wt.js:32:5
-- (Use node --trace-warnings ... to show where the warning was created)
-- (node:1056) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by
-- throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
-- (node:1056) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
-- <-- This process hangs

-- Output should be:
-- {"organization_name":"Telenet BVBA","region":"Flanders","accuracy":5,"asn":6848,"organization":"AS6848 Telenet BVBA","timezone":"Europe/Brussels","longitude":"4.4487","country_code3":"BEL","area_code":"0","ip":"81.83.67.231","city":"Mortsel","country":"Belgium","continent_code":"EU","country_code":"BE","latitude":"51.1662"}

in Playground:

[TypeError: Failed to fetch] ← probably same error

Example 2: await outside of flow

Windows 10 / Playground:  same error

Example 3: await block:

Windows 10:

  await:
	^

Expecting one of lineBreak, conditional, fullConditional, function, symbol, parameter, number, array, string, formattedString, hashmap, propertyAccess, range, rangeFull, rangeBy, byRange, ranger, slice, set, wrapped, awaited, parallelFn, null, true, false, inCheck, group, assignment, arrowAssignment, math, comparison, logical, logicalNot, call, imported, outdent but encountered colon

Playground:   same error

Example 4: await [] same error as Example 3
Example 5: await keyword: same error as Example 3

To Reproduce
Steps to reproduce the behavior:

  1. Run code samples on page
  2. See error

Expected behavior
json outputs of the fetch commands

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

• OS: Windows 10 + Playground
• Clio: 0.8.1
• Node: v14.16.1
• NPM: 6.14.12

Possible solutions

If fix is not evident, either remove the section (temporarily) or write a header:
** WIP: In the current version 0.8.1 these code examples don't work **

Additional context
It was mention on Telegram that it would be fixed in v0.8, but it isn't

@Ivo-Balbaert Ivo-Balbaert added the bug Something isn't working label Jul 4, 2021
@pouya-eghbali
Copy link
Member

This issue is fixed, for some reason Gitbook was building the old documentation source files.

@Ivo-Balbaert
Copy link
Contributor Author

After installing Clio 0.8.2 , creating a new project and copying the code from the async/await example in a project, I still get the same error in Windows 10:

D:\Clio\own_projects\async1>clio run
Info: Compiling from "clio.toml"
Info: Creating build for target "js"
√ Compiling source...
√ Adding Clio start script...
√ Installing npm dependencies (this may take a while)...

@ start D:\Clio\own_projects\async1\build
node .clio/index.js

(node:10332) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined
at D:\Clio\own_projects\async1\build\main.clio.js:1:187
at run (D:\Clio\own_projects\async1\build\node_modules\clio-run\src\index.js:106:26)
at async D:\Clio\own_projects\async1\build\node_modules\clio-run\src\runners\wt.js:32:5
(Use node --trace-warnings ... to show where the warning was created)
(node:10332) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:10332) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

All async/await programs: On Playground give the error:
[TypeError: Failed to fetch]

@pouya-eghbali
Copy link
Member

(node:10332) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined

I forgot the fact that fetch is browser only and the example does not run in node without first installing and importing node-fetch. I'll update the documentation, maybe come up with another async / await example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants