Skip to end of metadata
Go to start of metadata

This document summarizes the kinds of exceptions you may encounter when deploying or running an API Runtime Services application, or when installing or upgrading the acs NPM package on your system.

The appc cloud list and the appc cloud loglist CLI commands are used to troubleshoot deployment or runtime issues. Note that the appc cloud loglist may not immediately retrieve the latest logs from the server; you may need to wait a few seconds and try running the command again. Also, users should not expect this command to pull logs from the start date; the output will always return the latest logs. For example, if a start date is used and there are more than a 1000 lines up through today's date from the start date, the logs will only return a page with lines starting from today's date going back to the start date and not from the start date to today.

Exceptions are thrown upon deployment

Exception in app.js outside start() method

The following code references an undefined variable outside application's start() method.

In this scenario, the Message field of the appc cloud list and the appc acs loglist output indicates a ReferenceError and the name and location of the reference. The Status field of the appc cloud list command is set to "Failed to deploy"

Exception inside app.js start() method

The following code references an undefined variable inside application's start() method. 

In this scenario, the Message field of the appc cloud list and the  appc cloud loglist output indicates a ReferenceError and the name and location of the exception. The Status field of the appc cloud list command is set to "Failed to deploy"

Exception in a controller, outside of a function

The following code references an undefined variable inside a controller, outside any function definition: 

When accessing the application and hitting the controller over HTTP, it returns the following error: 

In this scenario, the appc cloud list output doesn't indicate a problem, but the appc cloud loglist indicates a ReferenceError and the name and location of the exception. 

Exceptions are thrown at runtime

Exception in synchronous calls handling requests

The following code references an undefined variable inside a controller function. 

In this scenario, the appc cloud list output doesn't indicate a problem, but the appc cloud loglist indicates a ReferenceError and the name and location of the exception. 

The response when accessing the application and hitting that function indicates the name and location of the reference error:

Exception in asynchronous callbacks handling requests (or background jobs)

The following code sample uses the setTimeout() method to asynchronously call a function that contains an exception. 

In this scenario when accessing the application over HTTP and hitting the function, the following error is returned:

In this scenario, the appc cloud loglist indicates a ReferenceError and the corresponding stack trace; appc cloud list does not indicate any problem. 

Application crashes while handling requests

The following code has request handler that quickly uses up available memory, causing the application to crash. 

The appc cloud loglist output indicates "FATAL ERROR: JS Allocation failed - process out of memory"; appc cloud list doesn't indicate any problem. 

Application crashes while running background jobs

The following code causes the application to run out of memory and crash while processing a setTimeout() function call. 

The appc cloud loglist output indicates "FATAL ERROR: JS Allocation failed - process out of memory"; appc cloud list doesn't indicate any problem. 

Installation errors

This section describes issues you may encounter when installing or upgrading API Runtime Services using NPM.

Error: ENOENT, no such file or directory

API Runtime Services installation fails with the following error: 

To resolve, try deleting your ~/.npm folder and cleaning the NPM cache, then re-installing: