Expand my Community achievements bar.

Deployed Mesh project on Aio gives 503 sometimes or different behavior

Avatar

Community Advisor and Adobe Champion

Hi Team,

 

I have created mesh project and it is running on local. Then i have created aio project using aio app init and aligned my mesh project to myaioproject/actions/mesh/<all files...>

Then i have created index.js file as entry file inside

myaioproject/actions/mesh/index.js

then i have run npx mesh build and npx mesh dev under myaioproject/actions/meshand project is running fine

manifest.yml file

packages:
  meshwebshop:
    actions:
      mesh:
        function: actions/mesh/index.js
        web: true
        runtime: 'nodejs:18'
        inputs:
          LOG_LEVEL: 'debug'

 

 

Below is index.js

/*
* <license header>
*/

/**
 * This is a sample action showcasing how to access an external API
 *
 * Note:
 * You might want to disable authentication and authorization checks against Adobe Identity Management System for a generic action. In that case:
 *   - Remove the require-adobe-auth annotation for this action in the manifest.yml of your application
 *   - Remove the Authorization header from the array passed in checkMissingRequestInputs
 *   - The two steps above imply that every client knowing the URL to this deployed action will be able to invoke it without any authentication and authorization checks against Adobe Identity Management System
 *   - Make sure to validate these changes against your security requirements before deploying the action
 */


const fetch = require('node-fetch')
const { Core } = require('@adobe/aio-sdk')
const { errorResponse, getBearerToken, stringParameters, checkMissingRequestInputs } = require('../utils')
const { Mutation } = require('./resolvers/index');

// main function that will be executed by Adobe I/O Runtime
async function main (params) {
  // create a Logger
  const logger = Core.Logger('main', { level: params.LOG_LEVEL || 'info' })

  try {
    // 'info' is the default level if not set
    logger.info('Calling the main action')

    // log parameters, only if params.LOG_LEVEL === 'debug'
    logger.debug(stringParameters(params))
 
  const brandId = params.query.match(/brandId:\s*"([^"]+)"/)?.[1];

   
    const content = await Mutation.import(null, { brandId: brandId });
    const response = {
      statusCode: 200,
      body: content
    }

    // log the response status code
    logger.info(`${response.statusCode}: successful request`)
    return response
  } catch (error) {
    // log any server errors
    logger.error(error)
    // return with 500
    return errorResponse(500, 'server error', logger)
  }
}

exports.main = main
 
Sometimes i get 503 service not available error & process starts in background.. print in logs
 
Get 200 ok when only hardcoded response is added and no api interaction in the resolvers.
 
now getting no brandid found.
I have run below commands still no luck
at root of project:
$ rm -rf .aio dist
aio app depoy
 
even did aio app undeploy then deploy still same.
 
Anybody help us here?
Thanks
Heena
3 Replies

Avatar

Community Advisor

Hi @HeenaMadan ,

The 503 errors and erratic behavior you're facing when deploying your Adobe I/O App Builder (AIO) + GraphQL Mesh project typically arise due to one or more of the following issues:

1. Asynchronous Issues or Cold Start Timeouts

  - Adobe I/O Runtime (based on Apache OpenWhisk) has a cold start time (~3–5 seconds).

  - If your Mutation.import() method or other Mesh API resolver calls are async-heavy, they may fail to resolve in time under cold starts.

2. Missing or Malformed Inputs (brandId)

Your code uses regex to extract brandId from a GraphQL-style string:

const brandId = params.query.match(/brandId:\s*"([^"]+)"/)?.[1];

If params.query is undefined or not structured as expected, brandId will be undefined, breaking downstream logic.

3. Mesh Server Not Bootstrapped Correctly in Adobe I/O Action

  - Mesh projects typically spin up a server or use heavy GraphQL code requiring pre-built schema loading.

  - You mentioned npx mesh dev works locally, but in Adobe Runtime, there's no persistent server only cold-started stateless functions.

4. Missing @adobe/aio-sdk Handling for Async Errors

   - If a Promise is unresolved or a GraphQL execution throws unhandled exceptions, OpenWhisk might return 503.

Solution:

1. Ensure Mutation.import() is not undefined

Make sure resolvers/index.js exports Mutation.import properly and doesn’t rely on in-memory cache or Node.js-specific state.

// resolvers/index.js
const importHandler = async (_, { brandId }) => {
  if (!brandId) throw new Error('brandId not provided');
  // simulate response or actual API call
  return { message: `Data imported for brand ${brandId}` };
};

exports.Mutation = {
  import: importHandler
};


Regards,
Amit

Avatar

Community Advisor and Adobe Champion

Thanks Amit to share this info.. very helpful.

i have a job which process around 0.3-0.5 million records and after processing need to push data to elastic and magento.

single node js mesh process deployed on aio gives 503 error service not available error and as per your info cold starts etc, i have created node js file which will call my mesh endpoint and do processing but with one cursor at a time. tested for around 100 cursors, its fine.

so do you think aio can handle this easily or any suggestion?

Also could you share official docs for Adobe I/O Runtime (based on Apache OpenWhisk)  as i can see here handling multiple data better have queue. Or i can think we can do via  chunking.

 

many thanks

Avatar

Employee
Employee

Hi @HeenaMadan 

 

> i have a job which process around 0.3-0.5 million records and after processing need to push data to elastic and magento.

 

Is it a long-running async function or 0.5M requests to App Builder action?

 

> single node js mesh process deployed on aio gives 503 error service not available error and as per your info cold starts etc,

 

Is it happening for the first request? When do you receive a 503?

 

> i have created node js file which will call my mesh endpoint and do processing but with one cursor at a time. tested for around 100 cursors, its fine. so do you think aio can handle this easily or any suggestion?

 

Can you add an arch diagram? What's a cursor here? I don't see a reason why App Builder could not handle your use case. Maybe you can supply an arch diagram and I can confirm. 

 

> Also could you share official docs for Adobe I/O Runtime

https://developer.adobe.com/app-builder/docs/guides/runtime_guides/ 

 

as i can see here handling multiple data better have queue. Or i can think we can do via  chunking.

App Builder also offers Custom events which are synonyms to using a message bus. You can publish events and then process them from the queue - thereby adding a buffer 

 

Manik