## TL;DR

A task resolves undefined when the plugin function returns nothing, so return a value or a promise from every task handler. Check the plugins file for a missing return, especially in async handlers where the promise was created but never returned.

## The query

```text
cypress cy.task() returned undefined from plugins file
```

## Use this when

- cy.task() yields undefined
- a seeding task silently does nothing
- plugin file changes seem to have no effect

## Not for

- tasks that throw errors (read the stack trace)
- tasks that time out
- browser-side code issues

## Steps

1. Open the plugins file and find the task by name in the object passed to on('task', ...). Expected output: the task name exists in the registered task map.
2. Read the handler and confirm it returns something: a plain value for sync work, or the promise for async work. Expected output: a return statement on every code path of the handler.
3. If the handler is async, make sure the promise chain is returned, not just created inside the function body. Expected output: the keyword return precedes the async call or the awaited result.
4. Restart the Cypress runner so the plugins file reloads, then call the task from a spec and log the result. Expected output: the logged value matches what the handler returned.
5. Add a small assertion on the task result in the spec so regressions surface immediately. Expected output: the spec fails loudly if the task ever returns undefined again.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_ZTRRFyRz9yUSoXA6W4EbfQ
