Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't trigger breakpoints in local development environment for mesh #224

Open
nellodb opened this issue Mar 13, 2025 · 4 comments
Open

Can't trigger breakpoints in local development environment for mesh #224

nellodb opened this issue Mar 13, 2025 · 4 comments

Comments

@nellodb
Copy link

nellodb commented Mar 13, 2025

I'm on Mac OS and Node 20 installed via nvm, here's my aio CLI version result

 $ aio --version
@adobe/aio-cli/10.3.2 darwin-x64 node-v20.11.1

It was installed via npm install -g @adobe/aio-cli

I've been trying to run a mesh locally. So I'm going off this guide and this one for "Command Reference"

So I run the command which I find in the "Example"

aio api-mesh:init myMesh --path ./mesh_examples --git Y --package-manager yarn

and I get

aio api-mesh:init myMesh --path ./mesh_examples --git Y --package-manager yarn
 ›   Error: Expected --git=Y to be one of: y, n
 ›   See more help with --help

Then I switch to "y" and I get

aio api-mesh:init myMesh --path ./mesh_examples --git y --package-manager yarn
 ›   Error: Unexpected arguments: --package-manager, yarn
 ›   See more help with --help

Then I end up removing that parameter and I select yarn manually. Packages get fetched and I get a

[...]
Local workspace created successfully

So I cd into mesh_examples, modify the .env to point to my COMMERCE_ENDPOINT, and I run aio api-mesh run mesh.json

Here's what I get

 $ aio api-mesh run mesh.json
The provided mesh contains placeholders. Starting mesh interpolation process.
This is path:  /Users/nello/Desktop/Work/example/mesh_examples
{"level":30,"time":1741883110986,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":"Beginning mesh build for meshId: testMesh"}
{"level":30,"time":1741883110987,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":"Creating /Users/nello/Desktop/Work/example/mesh_examples/testMesh folder"}
{"level":30,"time":1741883110987,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":"Writing .meshrc.json file: {\"sources\":[{\"name\":\"AdobeCommerceAPI\",\"handler\":{\"graphql\":{\"endpoint\":\"https://adobe-preprod.REDACTED.com/graphql\"}}}],\"plugins\":[{\"httpDetailsExtensions\":{}}],\"additionalResolvers\":[]}"}
{"level":30,"time":1741883110988,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":"chmod 775 on .meshrc.json file....."}
{"level":30,"time":1741883110988,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":"running graphqlMesh()....."}
{"level":30,"time":1741883113943,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":"Build process exited with code 1"}
{"level":50,"time":1741883113944,"pid":38473,"hostname":"MacBook-Pro-di-Nello.local","msg":false}
 ›   Error: Building Mesh with config: /Users/nello/Desktop/Work/example/mesh_examples/testMesh
 ›   💡 🕸️  Mesh Cleaning existing artifacts
 ›   💡 🕸️  Mesh Reading the configuration
 ›   💥 🕸️  Mesh TypeError: HandlerCtor is not a constructor
 ›       at /Users/nello/.local/share/@adobe/aio-cli/node_modules/@graphql-mesh/config/cjs/process.js:117:28
 ›       at async /Users/nello/.local/share/@adobe/aio-cli/node_modules/@graphql-mesh/config/cjs/process.js:96:17
 ›       at async Promise.all (index 0)
 ›       at async Promise.all (index 0)
 ›       at async processConfig (/Users/nello/.local/share/@adobe/aio-cli/node_modules/@graphql-mesh/config/cjs/process.js:88:114)
 ›       at async Object.handler (/Users/nello/.local/share/@adobe/aio-cli/node_modules/@graphql-mesh/cli/cjs/index.js:297:32)
 ›

Edit 1:

The plugins:install command gives me a billions warning aswell, if it might help pointing in the right direction...:

aio plugins:install @adobe/aio-cli-plugin-api-mesh

npm warn ERESOLVE overriding peer dependency
npm warn While resolving: @adobe/[email protected]
npm warn Found: @graphql-mesh/[email protected]
npm warn node_modules/@graphql-mesh/types
npm warn   peer @graphql-mesh/types@"^0.91.12" from @graphql-mesh/[email protected]
npm warn   node_modules/@graphql-mesh/cache-localforage
npm warn     @graphql-mesh/cache-localforage@"0.7.20" from @graphql-mesh/[email protected]
npm warn     node_modules/@graphql-mesh/config
npm warn   22 more (@graphql-mesh/cli, @graphql-mesh/utils, ...)
npm warn
npm warn Could not resolve dependency:
npm warn peer @graphql-mesh/types@"0.91.15" from @adobe/[email protected]
npm warn node_modules/@adobe/plugin-source-headers
npm warn   @adobe/plugin-source-headers@"^0.0.1" from @adobe/[email protected]
npm warn   node_modules/@adobe/aio-cli-plugin-api-mesh
npm warn
npm warn Conflicting peer dependency: @graphql-mesh/[email protected]
npm warn node_modules/@graphql-mesh/types
npm warn   peer @graphql-mesh/types@"0.91.15" from @adobe/[email protected]
npm warn   node_modules/@adobe/plugin-source-headers
npm warn     @adobe/plugin-source-headers@"^0.0.1" from @adobe/[email protected]
npm warn     node_modules/@adobe/aio-cli-plugin-api-mesh
[... many more ...]

Installing it through the -g flag suggested in this repo gives me a:

aio plugins:install -g @adobe/aio-cli-plugin-api-mesh
 ›   Error: Nonexistent flag: -g
 ›   See more help with --help

Am I going at this in the wrong direction?
Thanks

@kmaschi
Copy link
Member

kmaschi commented Mar 14, 2025

Hi @nellodb

You are going in the right direction. When in doubt, using the --help flag to get details on the command should steer you in the right direction.

% aio api-mesh:init --help                                                     
This command will create a workspace where you can organise your API mesh configuration and other files

USAGE
  $ aio api-mesh init PROJECTNAME [-p <value>] [-m npm|yarn] [-g y|n]

ARGUMENTS
  PROJECTNAME  Project name

FLAGS
  -g, --git=<option>             <options: y|n>
  -m, --packageManager=<option>  <options: npm|yarn>
  -p, --path=<value>             [default: .]

DESCRIPTION
  This command will create a workspace where you can organise your API mesh configuration and other files

EXAMPLES
  API mesh workspace init

    $ aio api-mesh init commerce-mesh

  API mesh workspace init with flags
  1. The flags and their values are case sensitive and you correctly addressed this with the git flag argument.

  2. You were providing a flag package-manager, but the correct usage for this would have either been -m or --packageManager.

  3. The error building mesh is not expected assuming a well structured mesh config file.

The aio CLI uses ~/.local/share/@adobe/aio-cli for node_modules used by itself and plugins. Multiple plugins may be using similar dependencies which are hoisted here. This exists outside of your project and outside of nvm's version specific directories for global node modules.

Could you provide an output of the aio plugins currently in use and their versions? You can get this by running the aio plugins command.

@nellodb
Copy link
Author

nellodb commented Mar 14, 2025

Thanks for the reply @kmaschi , yeah I get that the commands are case-sensitive, I take the devdocs has a few issues in the example parameters, no big deal.

I've done some progress since yesterday and after having installed 5.2.1-beta it now does look like it's starting properly (there's a bug when tenantFiles directory is not there I think, I just create it manually) but the debugger won't be triggered on breakpoints set in the tenantFiles directory and I did very little progress in this direction.

I have downgraded back to some pretty old versions which I've seen in videos were triggering the breakpoint but I'd rather not go in that direction and to be honest they do not break even in those versions for my current environment.

I can see from this file /Users/nello/.local/share/@adobe/aio-cli/node_modules/@adobe/aio-cli-plugin-api-mesh/src/server.js that the commandArgs actually has the inspect-port there, so might it be due to wrangler being pinned to an older version such as "wrangler": "3.80.4", ?

I see here it says As of Wrangler 3.9.0, you can debug via breakpoints in your Worker. Or is that just for remote Cloudflare workers?

My launch.json is quite basic:

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Debug Mesh",
			"port": 9229,
			"request": "attach",
			"skipFiles": ["<node_internals>/**"],
			"type": "node"
		}
	]
}

The mesh.json is also pretty barebone, I'm trying things out following this API Mesh Deep Dive video: https://www.youtube.com/watch?v=5RSivN9EGdk

extending the storeConfig for a GraphQL endpoint prefixed via transform. My current mesh is:

{
  "meshConfig": {
    "responseConfig": {
        "headers": {
          "Cache-Control": "max-age=3600,min-fresh=6,stale-if-error=20,public,must-revalidate",
          "Connection": "keep-alive"
        },
        "CORS": {
          "origin": "*",
          "methods": [
            "GET",
            "POST",
            "OPTIONS"
          ]
        }
    },
    "sources": [
      {
        "name": "MagentoGraphQL",
        "handler": {
          "graphql": {
            "endpoint": "https://adobe-preprod.REDACTED.com/graphql",
            "operationHeaders": {
              "store": "{context.headers['store']}",
              "Authorization": "{context.headers['Authorization']}"
            },
            "useGETForQueries": true
          }
        },
        "transforms": [
          {
              "prefix": {
                  "includeRootOperations": true,
                  "value": "Core_"
              }
          }
        ]
      }
    ],
    "additionalTypeDefs": "extend type Core_StoreConfig { announcement: String }",
    "additionalResolvers": ["./additional-resolvers.js"]
  }
}

Thanks!

@nellodb
Copy link
Author

nellodb commented Mar 14, 2025

Just to be thorough, here's the aio plugins result as-of now:

> aio plugins                                                  
@adobe/aio-cli-plugin-api-mesh 5.2.1-beta (5.2.1-beta)

and here's the additional-resolvers.js:

module.exports = {
  resolvers: {
      Core_StoreConfig: {
          announcement: {
              selectionSet: '{ announcement }',
              // root, args, context, info
              resolve: () => {
                return "hello world";
              },
          },
      },
  },
};

The debug command I'm running is yarn debug mesh_livesearch.json

Thank you!

@nellodb nellodb changed the title Can't run local development environment for mesh Can't trigger breakpoints in local development environment for mesh Mar 14, 2025
@kmaschi
Copy link
Member

kmaschi commented Mar 19, 2025

Thank you for the context. I can confirm that we can replicate this problem and we will be looking to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants