Local development tips and FAQs

For a walk-through of the local development process, check out the local development guide.

Arbitrary IO and Debug.trace statements are not supported in production on the Cloud

For security reasons, functions which run arbitrary IO (like printLine) and some debugging functions like Debug.trace are not available in the Cloud, so you should avoid using them in your production code. Instead, use the Log ability to log messages to the Cloud's logging system. There are some handy functions in the Log ability for logging messages at different levels, like Log.info, Log.warn, and Log.error.

Read more about the Log ability here.

Test web-services locally with the Cloud.main.local.serve handler

If you would like to run a local service and keep it around for testing with CURL or the browser, you should use the Cloud.main.local.serve version of the local cloud handler. The Cloud.main.local handler will exit immediately after starting the service, so it is primarily useful for Unison-native services, one-shot unit tests of services, or compute jobs.

Write an HTTP service and interact with it locally

The Environment type does not just mean "prod" vs "local"

It's easy to think of the Environment type as a flag for determining "Prod" vs "Staging" vs "Local". Instead, think of an Environment as describing a "configuration environment". While your Environment.Config values might indeed be different between different environments, the Environment type is a broad way of scoping configuration values and resources like databases and services to a particular context.

Read more about using Environments in the Cloud

You cannot call a deployed Unison native service in production from a local test

Local testing of deployed Http services is easily supported via regular Http requests, but services that are dependent upon the Cloud's own serialization layer cannot be called across deployment boundaries. You can always run and call your native service locally or plan on deploying your native service to the Cloud and write a separate Cloud job that issues a test request against it.

The Services ability describes native service interactions