---
title: OutcomeUnknown
description: The luna stopped while your call was running, so nobody knows whether its writes were kept.
related:
  - /lunas/call-another-luna
  - /concepts/the-life-of-a-luna
  - /errors
---

`OutcomeUnknown` means the luna stopped after it took your call, before it answered. The call may or may not have taken effect. The status is 502.

## Issue

A call fails with a message such as `the luna crashed: <REASON>`, or one saying the call stopped while it ran and may or may not have taken effect. In a luna, the `LunaCallError` has `kind: "OutcomeUnknown"` and `retryable: true`.

## Cause

The luna stopped while the call ran. A crash in the luna's code does this, and so does a handler that keeps its thread busy for 30 seconds without awaiting. The luna starts again on its next call.

Its writes are kept only if they were stored before it stopped. From outside, nobody can tell which happened.

`OutcomeUnknown` differs from [`Unavailable`](/errors/unavailable). `Unavailable` means the call never started, so a retry is always safe. It also differs from [`OutOfMemory`](/errors/out-of-memory), where Luna knows the call did not finish.

## Solution

Retry only a call that is safe to run twice. Give each write an idempotency key, and a retry with the same key returns the first call's result instead of running again.

Over HTTP, send the `idempotency-key` header.

```bash
curl -X POST "$LUNA_URL/List/groceries/add" \
  -H "luna-key: $LUNA_KEY" \
  -H "Content-Type: application/json" \
  -H "idempotency-key: <ORDER_ID>" \
  -d '{"text":"milk"}'
```

From a luna, pass `idempotencyKey` to [`ctx.call`](/sdk/ctx).

```ts luna/lunas/shop.ts
await ctx.call(Wallet, { id: ctx.key.id }).charge({ amount }, { idempotencyKey: `order-${orderId}` });
```

When a call with an idempotency key loses its luna in flight, Luna sends it again once before it answers. Find the crash with [`luna logs`](/cli/logs) `--event crash`, and break long work into steps that await.
