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

CI Docker String.repeat error #25

Open
b3nThomas opened this issue Feb 10, 2022 · 0 comments · May be fixed by #26
Open

CI Docker String.repeat error #25

b3nThomas opened this issue Feb 10, 2022 · 0 comments · May be fixed by #26

Comments

@b3nThomas
Copy link

b3nThomas commented Feb 10, 2022

Hi there,

While running v1.6.0 of this package in Jenkins CI via Docker, I receive the following error which fails my build, even though the deployment succeeded:

14:06:45    site: 
14:06:45      appUrl:         https://xxxxxxxxxx.cloudfront.net/
14:06:45      bucketName:     xxxxxxxxxx
14:06:45      distributionId: xxxxxxxxxx
14:06:45  
14:06:45    error:
14:06:45    RangeError: Invalid count value
14:06:45      at String.repeat (<anonymous>)
14:06:45      at runComponents (/usr/src/app/node_modules/@serverless/cli/src/index.js:231:18)
14:06:45      at runMicrotasks (<anonymous>)
14:06:45      at processTicksAndRejections (node:internal/process/task_queues:96:5)
14:06:45  �[G�[G
14:06:45    317s › site › RangeError: Invalid count value

The error appears to originate here:

cli/src/index.js

Lines 229 to 234 in a4df848

const borderLength = Math.min(notification.message.length, process.stdout.columns - 2)
context.log(
`${'*'.repeat(borderLength)}\n ${chalk.bold(notification.message)}\n ${'*'.repeat(
borderLength
)}\n`
)

I've been reading around online and have found that process.stdout.columns can often come back as 0/null/undefined during CI, which would explain why String.repeat is throwing because of a negative count argument:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat#using_repeat

If this could please be refactored to handle this scenario that'd be amazing. Maybe something like this where we don't bother with a border if the columns can't be derived:

         const borderLength = Math.min(notification.message.length, process.stdout.columns - 2)
         const border = borderLength > 0 ? `${'*'.repeat(borderLength)}\n` : '';
         context.log( 
           `${border}  ${chalk.bold(notification.message)}\n  ${border}` 
         )

Many thanks, Ben

@b3nThomas b3nThomas linked a pull request Mar 9, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant