Skip to content
This repository was archived by the owner on Jul 12, 2025. It is now read-only.
This repository was archived by the owner on Jul 12, 2025. It is now read-only.

SyntaxError: await is only valid in async function #218

@geohuz

Description

@geohuz

Running example code from task api doc throw the error: SyntaxError: await is only valid in async function

Steps to reproduce

Just running the following example code:

const { task } = require('folktale/concurrency/task');

const delay = (time) => task(
  (resolver) => {
    const timerId = setTimeout(() => resolver.resolve(time), time);

    resolver.cleanup(() => {
      clearTimeout(timerId);
    });

    resolver.onCancelled(() => {
      /* does nothing */
    });
  }
);

const result = await delay(100).run().promise();

Expected behaviour

Should be run without any error.

Environment

(Describe the environment where the problem happens. This usually includes:

  • OS: macos
  • JavaScript VM
  • Folktale version : 2.3.2
    )

Additional information

node v8.12.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions