https://serverless-stack.com/ logo
#sst
Title
# sst
i

Ibrael Espinosa

03/15/2022, 5:10 PM
this is becoming very urgent as the web platform I'm working on is currently facing issues
r

Ross Coundon

03/15/2022, 5:11 PM
Can you downgrade SST while you figure it out?
i

Ibrael Espinosa

03/15/2022, 5:12 PM
I can, but then have to do a tone of modifications, I've already tracjed the issue to the aws-cdk-lib, where inside App, in the method loadContext, this.node is undefined
I suppose that new App is called from sst
and this is the debugApp, not the real App
debugStack
r

Ross Coundon

03/15/2022, 5:48 PM
Are you using version 2.15.0 of aws-cdk-lib and 2.15.0-alpha.0 for your authorizers?
i

Ibrael Espinosa

03/15/2022, 10:27 PM
yes
i've just updated fresh today to the last version and after a clean install of my vendors nothing is working for deploy
r

Ross Coundon

03/15/2022, 10:32 PM
What version did you upgrade from?
i

Ibrael Espinosa

03/15/2022, 10:32 PM
0.53.4
aparently, the issue is raised even before the main function, this is raised while setting the debugApp
becase i've set a simple console.log at the very begining of the function and is not called
r

Ross Coundon

03/15/2022, 10:35 PM
Have you followed the instructions for moving from CDK v1 to CDK v2?
i

Ibrael Espinosa

03/15/2022, 10:42 PM
yes I did it already , but right now i'm only using the sst constructors directly, without any special aws-cdk-lib constructor
my main function is not even called, and i've traced the issue tio the creation of the debugApp for the debug stack
r

Ross Coundon

03/15/2022, 10:48 PM
I think you need to share your index.ts and stack definition. Maybe delete your package.lock/yarn.lock and node_modules and reinstall
i

Ibrael Espinosa

03/15/2022, 10:56 PM
Copy code
/* eslint-disable no-new */
/* eslint-disable no-unused-vars */

// import MyStack from "./MyStack";
import * as sst from '@serverless-stack/resources'
import { RemovalPolicy } from '@aws-cdk/core'
import AuthStack from './Auth'
import StorageStack from './Storage'
import AppSyncStack from './ApiSync'
//import FrontendStack from './Frontends'
import WebappStack from './Webapp'
import StorybookStack from './Storybook'
import BackofficeStack from './Backoffice'
import CatalogStack from './Catalog'
import { UsersModuleStack } from './UsersModuleStack'

export default function main(app: <http://sst.App|sst.App>): void {
    console.log(app)
    // Set default runtime for all functions
    app.setDefaultFunctionProps({
        runtime: 'nodejs14.x'
    })

    // Remove all resources when the dev stage is removed
    if (!['prod', 'staging', 'stage'].includes(app.stage)) {
        app.setDefaultRemovalPolicy(RemovalPolicy.DESTROY)
    }

    const storage = new StorageStack(app, 'Storage', {
        description: 'Storage'
    })

    /*const usersModuleStack = new UsersModuleStack(app, 'UsersModule', {
        description: 'Fuck the users'
    })

    const authStack = new AuthStack(app, 'Auth', {
        props: {
            description: 'Auth stack'
        },
        bucket: storage.bucket,
        triggers: {
            createAuthChallenge: usersModuleStack.createAuthChallenge
        }
    })

    const catalog = new CatalogStack(app, 'Catalog', {
        description: 'Catalog'
    })
    const appsync = new AppSyncStack(app, 'AppSync', {
        description: 'GraphQL Api',
        auth: authStack.auth,
        dataSources: {
            offers: {
                table: catalog.offersTable.dynamodbTable
            },
            users: {
                table: usersModuleStack.usersTable.dynamodbTable
            },
            profiles: {
                table: usersModuleStack.profilesTable.dynamodbTable
            }
        }
    })*/

    new StorybookStack(app, 'Storybook', {
        props: {
            description: 'Storybook site'
        }
    })

    
}
already deleted yarn.lock and node_modules and reinstall fresh
bassically I've just commented everything inside main function, but it's not even called!
r

Ross Coundon

03/15/2022, 11:08 PM
Maybe also .build and .sst too
i

Ibrael Espinosa

03/15/2022, 11:10 PM
done right now, same error
Copy code
Look like you're running sst for the first time in this directory. Please enter a stage name you'd like to use locally. Or hit enter to use the one based on your AWS credentials (srvapp): 
Using stage: srvapp
Preparing your SST app

=======================
 Deploying debug stack
=======================

/home/ibra/accor/astore/node_modules/aws-cdk-lib/core/lib/app.js:1
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.attachCustomSynthesis=<http://exports.App|exports.App>=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cxapi=require("../../cx-api"),synthesis_1=require("./private/synthesis"),tree_metadata_1=require("./private/tree-metadata"),stage_1=require("./stage"),APP_SYMBOL=Symbol.for("@aws-cdk/core.App");class App extends stage_1.Stage{constructor(props={}){var _b,_c,_d;super(void 0,"",{outdir:(_b=props.outdir)!==null&&_b!==void 0?_b:process.env[cxapi.OUTDIR_ENV]});jsiiDeprecationWarnings.aws_cdk_lib_AppProps(props),Object.defineProperty(this,APP_SYMBOL,{value:!0}),this.loadContext(props.context),props.stackTraces===!1&&this.node.setContext(cxapi.DISABLE_METADATA_STACK_TRACE,!0);const analyticsReporting=(_c=props.analyticsReporting)!==null&&_c!==void 0?_c:props.runtimeInfo;analyticsReporting!==void 0&&this.node.setContext(cxapi.ANALYTICS_REPORTING_ENABLED_CONTEXT,analyticsReporting),((_d=props.autoSynth)!==null&&_d!==void 0?_d:cxapi.OUTDIR_ENV in process.env)&&process.once("beforeExit",()=>this.synth()),(props.treeMetadata===void 0||props.treeMetadata)&&new tree_metadata_1.TreeMetadata(this)}static isApp(obj){return APP_SYMBOL in obj}loadContext(defaults={}){for(const[k,v]of Object.entries(defaults))this.node.setContext(k,v);const contextJson=process.env[cxapi.CONTEXT_ENV],contextFromEnvironment=contextJson?JSON.parse(contextJson):{};for(const[k,v]of Object.entries(contextFromEnvironment))this.node.setContext(k,v)}}<http://exports.App|exports.App>=App,_a=JSII_RTTI_SYMBOL_1,App[_a]={fqn:"<http://aws-cdk-lib.App|aws-cdk-lib.App>",version:"2.15.0"};function attachCustomSynthesis(construct,synthesis){synthesis_1.addCustomSynthesis(construct,synthesis)}exports.attachCustomSynthesis=attachCustomSynthesis;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

TypeError: Cannot read property 'setContext' of undefined
    at DebugApp.loadContext (/home/ibra/accor/astore/node_modules/aws-cdk-lib/core/lib/app.js:1:1543)
    at new App (/home/ibra/accor/astore/node_modules/aws-cdk-lib/core/lib/app.js:1:698)
    at new DebugApp (/home/ibra/accor/astore/node_modules/@serverless-stack/resources/dist/DebugApp.js:31:9)
    at Object.<anonymous> (/home/ibra/accor/astore/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js:24:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

There was an error synthesizing your app.
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
c

Cristian Pallarés

03/16/2022, 6:54 AM
just wondering, did you solve the issue?
i

Ibrael Espinosa

03/16/2022, 6:59 AM
not yet
I'm still sruggling with
r

Ross Coundon

03/16/2022, 7:20 AM
One of the real experts will need to help @thdxr or @Frank
i

Ibrael Espinosa

03/16/2022, 11:09 AM
nothing yet
r

Ross Coundon

03/16/2022, 11:21 AM
They’ll be asleep
j

jamlen

03/16/2022, 4:57 PM
Is it related to this? Major changes to customizing
DebugStack
- https://github.com/serverless-stack/serverless-stack/releases/tag/v0.65.3
i

Ibrael Espinosa

03/16/2022, 5:01 PM
surely, but the debug stack is not even launching
Copy code
export function debugApp(app: <http://sst.App|sst.App>) {
    console.log(app)
    new sst.DebugStack(app, 'debug-stack', {
        stackName: app.logicalPrefixedName('live-debug'),
        synthesizer: new cdk.DefaultStackSynthesizer({
            qualifier: 'hello'
        })
    })

    cdk.Tags.of(app).add('test', `${app.stage}-${app.region}`)
}
no console.log is sown
shown
if tracked the issue and app.node is not set anytime
then, calling (this = app).node.setContext throw the error
j

jamlen

03/16/2022, 5:02 PM
do you really need to apply the tag of the debug stack? to test it could you remove that function completely and try starting?
i

Ibrael Espinosa

03/16/2022, 5:02 PM
at all, but that's not the point 😄
j

jamlen

03/16/2022, 5:03 PM
But if this is blocking you being able to deploy, then surely its better to remove the customisation of the debug stack and at least deploy... I'm sure that @Frank could wade in
i

Ibrael Espinosa

03/16/2022, 5:04 PM
I've just added the debugStack suite to your comment, for test purposes only, I dont need it specially
but, the point is that app is breaking while loading context
even before being passed as parameter for debugApp or main
@Frank Hi mate, hope you're doing well! A little help would be appreciated here 😄
t

thdxr

03/16/2022, 5:07 PM
I looked at this and don't immediately know what's going on
but I am less familiar with our debug stack
This seems to be coming from inside cdk - is it possible you're not on 2.15?
i

Ibrael Espinosa

03/16/2022, 5:14 PM
SST: 0.69.0 CDK: 2.15.0
clean install
and still having the same issue
Copy code
Preparing your SST app

TypeError: Cannot read property 'setContext' of undefined
    at App.loadContext (/home/ibra/accor/astore/node_modules/aws-cdk-lib/core/lib/app.ts:152:17)
    at new App (/home/ibra/accor/astore/node_modules/aws-cdk-lib/core/lib/app.ts:115:10)
    at new App (/home/ibra/accor/astore/node_modules/@serverless-stack/resources/src/App.ts:141:5)
    at Object.<anonymous> (/home/ibra/accor/astore/.build/run.js:68:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47
f

Frank

03/16/2022, 9:57 PM
Hey @Ibrael Espinosa, can you comment out all the stacks and the
DebugStack
in your
index.ts
, ie.
Copy code
import * as sst from '@serverless-stack/resources'

export default function main(app: <http://sst.App|sst.App>): void {
    console.log(app)
}
Run
sst build
and see if
console.log
is reached?
i

Ibrael Espinosa

03/16/2022, 10:40 PM
the log is the one before
l is never reached
@Frank
f

Frank

03/22/2022, 6:11 AM
Hey @Ibrael Espinosa, are you still having the issue? It seems the error comes pretty early. If you removed all ur Lambda code and all ur stack code, with just an empty
index.ts
, you’d still get the same error.
If that’s the case, could u zip up the project and DM it to me (assuming it doesn’t contain any sensitive data at this point). I will give it a try on my end.
i

Ibrael Espinosa

04/04/2022, 10:50 PM
@Frank sorry mate, this project ain't of my property, it's from my company and also already too big, and yes, it has a lot of sensitive information 😄
but i'm stil facing the issue
@Frank Hi Frank, after several days struggling with this issue, I've finally solved. The problem comes when aws-amplify is already set on the project, do to the fact that ams-amplify depends on cdk for their functionnality of "export as cdk" to be used as part of other stacks. the dependency is still on the the cdk v1, so, it "overwrites" aws-cdk on sst t the v1 version, which in fact does not come with the setContext method on app
when i removed aws-amplify from the project, it worked!
maybe this should be documented, because of aws-amplify it's a widely used feature from aws
2 Views