# How to tell the namespace is ready to be polled by workers

**URL:** <https://community.temporal.io/t/how-to-tell-the-namespace-is-ready-to-be-polled-by-workers/1606>\
**Category:** Community Support\
**Created:** [February 27, 2021, 8:38pm UTC](https://community.temporal.io/t/how-to-tell-the-namespace-is-ready-to-be-polled-by-workers/1606 "2021-02-27T20:38:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GreyTeardrop](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/greyteardrop/32/623_2.png) [@GreyTeardrop](https://community.temporal.io/u/GreyTeardrop)\
**Post date:** [February 27, 2021, 8:38pm UTC](https://community.temporal.io/t/how-to-tell-the-namespace-is-ready-to-be-polled-by-workers/1606/1 "2021-02-27T20:38:39Z")

</div>

Hi Temporal team!

I’m looking for ways to simplify Temporal development experience for new engineers from my organization. As part of that, I’ve created a small generic code that could automatically create a namespace on worker/starter application startup. The idea is to have it off for staging and production (so namespaces have to be manually created there) but be able to automatically create required namespaces on a local machine.

To do that, I make a `DescribeNamespace` call and it fails, make a `RegisterNamespace` call. This works fine in the sense that namespace is created and is visible in Temporal web, however, it’s not immediately “useful” as for ~10-15 seconds after namespace was created requests fail with

```auto
io.grpc.StatusRuntimeException: NOT_FOUND: namespace: basic_worker-namespace not found

	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.startWorkflowExecution(WorkflowServiceGrpc.java:2614)
	at io.temporal.internal.external.GenericWorkflowClientExternalImpl.lambda$start$0(GenericWorkflowClientExternalImpl.java:88)
	at io.temporal.internal.common.GrpcRetryer.retryWithResult(GrpcRetryer.java:97)
	at io.temporal.internal.external.GenericWorkflowClientExternalImpl.start(GenericWorkflowClientExternalImpl.java:81)

```

I tried to run another `DescribeNamespace` call after `RegisterNamespace` but it succeeds and indicated the namespace is already created. Same with `ListNamespaces`.

The best workaround I’ve found for now is to make a `GetWorkflowExecutionHistory` request for some fake workflow id. If it fails with status code `NOT_FOUND` I deduce the namespace is not propagated yet, once it fails with `INVALID_ARGUMENT` I assume the namespace is ready and I can let worker and client request go.

Is there a way to tell that the namespace is “ready” and other calls can be initiated? I feel I’m missing something pretty obvious.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 28, 2021, 7:29pm UTC](https://community.temporal.io/t/how-to-tell-the-namespace-is-ready-to-be-polled-by-workers/1606/2 "2021-02-28T19:29:25Z")

</div>

Each shard has its own namespace cache which is updated with up to 15 seconds delay. So even if you a call `GetWorkflowExecutionHistory` for some workflow ID succeeds it doesn’t mean that it is going to succeed for a different workflow ID as it can belong to another shard.

While it is technically possible to add a feature that would report namespace registration status watching all the namespace caches I don’t think we will have time to work on it in a near future.

So I would recommend adding 20-second sleep in your scripts after the namespace registration as a workaround.

---

<div class="post-metadata">

**Author:** ![GreyTeardrop](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/greyteardrop/32/623_2.png) [@GreyTeardrop](https://community.temporal.io/u/GreyTeardrop)\
**Post date:** [February 28, 2021, 7:51pm UTC](https://community.temporal.io/t/how-to-tell-the-namespace-is-ready-to-be-polled-by-workers/1606/3 "2021-02-28T19:51:07Z")

</div>

Thank you, Maxim!

I don’t see much value in automatic namespace registration outside of local environments and it’s totally not worth investing in a new API just for that use case.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 28, 2021, 7:59pm UTC](https://community.temporal.io/t/how-to-tell-the-namespace-is-ready-to-be-polled-by-workers/1606/4 "2021-02-28T19:59:27Z")

</div>

One possible option would be reducing cache refresh time for the local environment only. If filed [an issue](https://github.com/temporalio/temporal/issues/1336) to get this tracked.
