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

Weird Compilation Err in our Application code only in SLS version > 1.43.0 #6211

Open
prr19776 opened this issue Jun 5, 2019 · 5 comments
Open

Comments

@prr19776
Copy link

prr19776 commented Jun 5, 2019

We are seeing a lot of application errors which were not happening with version < =1.43.0, but when we got the 1.44.1 installed, it threw some weird errors. Not sure what has changed from the SLS perspective

typescript version : "2.9.2"

xxx@0.0.1 tsc C:***
tsc

src/enrichers/xxx.ts(43,3): error TS2554: Expected 0 arguments, but got 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! vehicle-enricher@0.0.1 tsc: tsc
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the vehicle-enricher@0.0.1 tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@prr19776
Copy link
Author

prr19776 commented Jun 5, 2019

_.chain(colorObject) //This is the line error occurs
.keys(colorObject)

@pmuens
Copy link
Contributor

pmuens commented Jun 5, 2019

Hey @prr19776 thanks for opening 👍

Could you share your serverless.yml config file? What plugins are you using?

@prr19776
Copy link
Author

prr19776 commented Jun 5, 2019

Im using these 3 plugins
plugins:

  • serverless-build-plugin
  • serverless-plugin-aws-alerts
  • serverless-prune-plugin

Redacted sls yaml

service: ${self:custom.pOwner}-${self:custom.pEnvironment}-lf-vehicle-enricher

custom:
prune:
automatic: true
number: 5
#-----------------------------------------------------------------------------

Mapping with respect to environment specific URL and serverless stage.

#-----------------------------------------------------------------------------

AWS account Id Map that would be used as a map for forming urns.

...
...

Region Map for deployment of lambda functions.

#KMS Encryption Key ID
...
...

EFC Urls by environment.

...
...

Media Urls by environment that would be appended to each of the hrefs.

...
...

EFC API Key by environment.

...
...

VIS Urls by environment.

...
...

Log Retention in Cloudwatch.

dev-log-retention: 5
test-log-retention: 5
e2e-log-retention: 5
qa-log-retention: 5
stage-log-retention: 5
prod-log-retention: 30
local-log-retention: 5

Log Level for debug logging.

dev-log-level: trace
test-log-level: trace
e2e-log-level: trace
qa-log-level: info
stage-log-level: info
prod-log-level: info
local-log-level: trace

Common Color Name feature indicator by env

...
...

#-----------------------------------------------------------------------------

Parameter block to define the tagging, naming and billing strategies

for this template.

#-----------------------------------------------------------------------------
...
...

Log Level - can be any of 'trace', 'debug', 'info', 'warn', 'error'

pLogLevel: ${self:custom.${self:custom.pEnvironment}-log-level}
pCommonColorNameInd: ${self:custom.${self:custom.pEnvironment}-commonColorName-Ind}
pRequestRetryAttemptCount: 3
pRequestRetryAttemptDelay: 2000
pRequestTimeout: 10000

Build related pramaters for serverless-build-plugin. Refer to the link below for more details

https://github.com/nfour/serverless-build-plugin/blob/master/docs/Install%20&%20Config.md

build:
method: bundle
sourceMaps: true
include:
- 'dist/**'
alerts:
stages: # Optionally - select which stages to deploy alarms to
- e2e
- prod
dashboards: false

topics:
  alarm: 
    topic: arn:aws:sns:${self:custom.pRegion}:${self:custom.pAccountId}:${self:custom.pOwner}-${self:custom.pEnvironment}-ops-alerts-${self:custom.pRegion}

definitions:  # these defaults are merged with your definitions 
  functionErrors:
    namespace: 'AWS/Lambda'
    metric: Errors
    threshold: 5 # Alert if more than 5 requests fails in a min.
    statistic: Sum
    period: 60
    evaluationPeriods: 1
    comparisonOperator: GreaterThanThreshold
    treatMissingData: notBreaching

provider:
name: aws
runtime: nodejs8.10
stage: dev
region: ${self:custom.pRegion}
memorySize: 512
timeout: 180
deploymentBucket: ${self:custom.pOwner}-${self:custom.pEnvironment}-serverless-${self:custom.pRegion}-deploys
iamRoleStatements:
- Effect: 'Allow'
Action:
- kinesis:Get*
- kinesis:Put*
- kinesis:DescribeStream
- kinesis:ListStreams
Resource:
- arn:aws:kinesis:${self:custom.pRegion}:${self:custom.pAccountId}:stream/${self:custom.pKinesisEnricherStream}
- arn:aws:kinesis:${self:custom.pRegion}:${self:custom.pAccountId}:stream/${self:custom.pKinesisVehicleGatewayStream}
- Effect: "Allow"
Action:
- kms:Decrypt
Resource: "arn:aws:kms:${self:custom.pRegion}:${self:custom.pAccountId}:key/${self:custom.${opt:stage}-key-id}"

Environment related variables.

environment:
OWNER: ${self:custom.pOwner}
DEPLOYED_VERSION: ${file(./dist/version.yml):version, "VERSION_UNKNOWN"}
RTI_ENVIRONMENT: ${self:custom.pEnvironment}
REGION: ${self:custom.pRegion}
LOG_LEVEL: ${self:custom.pLogLevel}
VEHICLE_ENRICHER_QUEUE: ${self:custom.pKinesisEnricherStream}
VEHICLE_GATEWAY_QUEUE: ${self:custom.pKinesisVehicleGatewayStream}
EFC_API_KEY: ${self:custom.pEfcApiKey}
EFC_BASE_URL: ${self:custom.pEfcBaseUrl}
VIS_BASE_URL: ${self:custom.pVisBaseUrl}
MEDIA_BASE_URL: ${self:custom.pMediaBaseUrl}
RETRY_ATTEMPT_COUNT: ${self:custom.pRequestRetryAttemptCount}
RETRY_ATTEMPT_DELAY: ${self:custom.pRequestRetryAttemptDelay}
REQUEST_TIMEOUT: ${self:custom.pRequestTimeout}
COMMON_COLOR_FEATURE_ENABLED: ${self:custom.pCommonColorNameInd}

Tagging for this stack.

stackTags:
Name: ${self:service}
Owner: ${self:custom.pOwner}
Vertical: ${self:custom.pVertical}
Env: ${self:custom.pEnvironment}
CostCenter: ${self:custom.pCostCenter}

plugins:

  • serverless-build-plugin
  • serverless-plugin-aws-alerts
  • serverless-prune-plugin

functions:
enricher:
name: ${self:service}
description: Listener responsible for enriching Vehicle Events. Kinesis Input [${self:custom.pKinesisEnricherStream}]
handler: dist/src/handler.enrichVehicles
events:
- stream:
arn: arn:aws:kinesis:${self:custom.pRegion}:${self:custom.pAccountId}:stream/${self:custom.pOwner}-${self:custom.pEnvironment}-vehicle-enricher-stream
batchSize: 10
startingPosition: LATEST
enabled: true
alarms:
- functionThrottles
- functionErrors
- name: customLogErrors
namespace: 'AWS/Lambda'
metric: CustomLogErrors
threshold: 0
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
pattern: 'ERROR'
treatMissingData: notBreaching
- name: customSecondsBehind
namespace: 'AWS/Lambda'
metric: CustomSecondsBehind
threshold: 0
statistic: Sum
period: 300
evaluationPeriods: 1
comparisonOperator: GreaterThanThreshold
pattern: '{$.secondsBehind > 60}' # alert if the requests are getting processed with more than 1 min of delay.
treatMissingData: missing
resources:
Description: '[Vehicle Enricher] Defines Vehicle Enrichment Lambda function and its resources'
Resources:
EnricherLogGroup:
Type: 'AWS::Logs::LogGroup'
Properties:
LogGroupName: /aws/lambda/${self:functions.enricher.name}
RetentionInDays: ${self:custom.${self:custom.pEnvironment}-log-retention}

@prr19776
Copy link
Author

prr19776 commented Jun 5, 2019

Just curious why is SLS yml relevant in this case, the compilation itself is failing and its pointing at an obscure place in the code where I'm using Lodash _.chain(obj).keys(obj)

But it only fails on > 1.43.0, everything remaining the same its failing on SLS yml and package.json

@prr19776
Copy link
Author

prr19776 commented Jun 5, 2019

Im able to see why this is failing, in the version > 1.43.0 serverless added the "@types/lodash" dependency, which is breaking the code compile.

I deleted the "@types/lodash" folder from the node_modules, then my code compiled

how do I ensure that this is circumvented? this looks like a breaking change in my opinion

image

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

No branches or pull requests

2 participants