# How to handle undefined signals

**URL:** <https://community.temporal.io/t/how-to-handle-undefined-signals/10692>\
**Category:** Community Support\
**Tags:** signals, typescript-sdk\
**Created:** [January 17, 2024, 5:56am UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692 "2024-01-17T05:56:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuvo\_Mondal](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shuvo_mondal/32/4790_2.png) [@Shuvo\_Mondal](https://community.temporal.io/u/Shuvo_Mondal)\
**Post date:** [January 17, 2024, 5:56am UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692/1 "2024-01-17T05:56:33Z")

</div>

I am new to temporal, and I want to handle if invalid signals passed to the workflow,  
I had defined 2 signals  
export const s1 = wf.defineSignal(‘s1signal’);  
export const s2 = wf.defineSignal(‘s2signal’);  
and in the workflow I had called setHandler for both s1 and s2  
during the workflow execution s1, s3 are the signals, I am passing, I am want to raise error if invalid signals are passed to the workflow.

---

<div class="post-metadata">

**Author:** ![bergundy](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/bergundy/32/900_2.png) [@bergundy](https://community.temporal.io/u/bergundy)\
**Post date:** [January 17, 2024, 7:12pm UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692/2 "2024-01-17T19:12:39Z")

</div>

Because signal handlers are dynamically registered, if a handler isn’t registered at the time a signal is received by the SDK, it is buffered in memory.

If you want a different behavior, you can implement a default signal handler to act as a catch-all and react to the situation.

What sort of error do you want to raise?  
If you raise an `ApplicationFailure`, the workflow will fail. If you raise a generic error, the workflow task will fail and your workflow will be “stuck”.  
The latter will let you fix the situation by installing a handler for the given workflow.

You may just want to log an error for visibility and avoid failing the task or the entire workflow.

---

<div class="post-metadata">

**Author:** ![Shuvo\_Mondal](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shuvo_mondal/32/4790_2.png) [@Shuvo\_Mondal](https://community.temporal.io/u/Shuvo_Mondal)\
**Post date:** [January 18, 2024, 5:53am UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692/3 "2024-01-18T05:53:16Z")

</div>

I just want to log error if an undefined or invalid signal lands on my workflow, which was not defined in my workflow, so can you please guide me how can I achieve these ?

---

<div class="post-metadata">

**Author:** ![bergundy](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/bergundy/32/900_2.png) [@bergundy](https://community.temporal.io/u/bergundy)\
**Post date:** [January 18, 2024, 11:09pm UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692/4 "2024-01-18T23:09:00Z")

</div>

Use [Namespace: workflow | Temporal TypeScript SDK API Reference](https://typescript.temporal.io/api/namespaces/workflow#setdefaultsignalhandler) and log the error:

```ts
import * as workflow from '@temporalio/workflow'

export async function myWorkflow() {
  workflow.setHandler(mySignalHandler, () => {})
  // ... register all of the other known handlers here
  workflow.setDefaultSignalHandler((signalName, ...args) => {
    workflow.log.error('unknown signal', { signalName })
  })
}

```

---

<div class="post-metadata">

**Author:** ![Shuvo\_Mondal](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shuvo_mondal/32/4790_2.png) [@Shuvo\_Mondal](https://community.temporal.io/u/Shuvo_Mondal)\
**Post date:** [January 19, 2024, 6:34am UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692/5 "2024-01-19T06:34:45Z")

</div>

**Thank you @bergundy** , I had handle the invalid or undefined signal using switch cases, I will integrate this to my to my code.

---

<div class="post-metadata">

**Author:** ![bergundy](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/bergundy/32/900_2.png) [@bergundy](https://community.temporal.io/u/bergundy)\
**Post date:** [January 19, 2024, 7:11am UTC](https://community.temporal.io/t/how-to-handle-undefined-signals/10692/6 "2024-01-19T07:11:15Z")

</div>

You don’t need switch cases, you can set a handler per signal.

Maybe it wasn’t clear but this comment `register all of the other known handlers here` tells you to register handlers above the “default” signal handler not in the body of that handler.
