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

fix: annotate ISC errors and split into to separate errors #1146

Merged
merged 6 commits into from Jul 18, 2022

Conversation

danez
Copy link
Contributor

@danez danez commented Jul 14, 2022

πŸŽ‰ Thanks for submitting a pull request! πŸŽ‰

Summary

Fixes #1145

Annotates the errors and also splits them into to errors to guide users into the right direction.


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code πŸ§‘β€πŸ’».
    This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing
    a typo or something that`s on fire πŸ”₯ (e.g. incident related), you can skip this step.
  • Read the contribution guidelines πŸ“–. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) πŸ§ͺ
  • Update or add documentation (if features were changed or added) πŸ“
  • Make sure the status checks below are successful βœ…

A picture of a cute animal (not mandatory, but encouraged)

@danez danez added the type: bug code to address defects in shipped code label Jul 14, 2022
@danez danez requested review from a team and jenae-janzen July 14, 2022 13:31
@github-actions
Copy link
Contributor

github-actions bot commented Jul 14, 2022

⏱ Benchmark results

Comparing with b0048a4

largeDepsEsbuild: 7.7s

⬆️ 4.76% increase vs. b0048a4

^                                                           7.7s  
β”‚                                                   7.4s    β”Œβ”€β”€β”  
β”‚                                                   β”Œβ”€β”€β”    |β–’β–’|  
β”‚                                                   |  |    |β–’β–’|  
β”‚                   6.2s             6s      6s     |  |    |β–’β–’|  
β”‚ ──5.9s────5.9sβ”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€5.8sβ”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€|β–’β–’|──
β”‚   β”Œβ”€β”€β”    β”Œβ”€β”€β”    |  |    β”Œβ”€β”€β”    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsNft: 40.5s

⬆️ 4.38% increase vs. b0048a4

^                                                          40.5s  
β”‚                                                  38.7s    β”Œβ”€β”€β”  
β”‚                                                   β”Œβ”€β”€β”    |β–’β–’|  
β”‚                                                   |  |    |β–’β–’|  
β”‚                                                   |  |    |β–’β–’|  
β”‚ ─────────────────────────────────────────29.8s────┼──┼────|β–’β–’|──
β”‚  29.2s   29.1s                            β”Œβ”€β”€β”    |  |    |β–’β–’|  
β”‚   β”Œβ”€β”€β”    β”Œβ”€β”€β”           26.8s            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            β”Œβ”€β”€β”            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |            |  |            |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    n/a     |  |    n/a     |  |    |  |    |β–’β–’|  
└───┴──┴────┴──┴────────────┴──┴────────────┴──┴────┴──┴────┴──┴──>
    T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsZisi: 55s

⬆️ 1.36% increase vs. b0048a4

^                                                  54.3s    55s   
β”‚                                                   β”Œβ”€β”€β”    β”Œβ”€β”€β”  
β”‚                                                   |  |    |β–’β–’|  
β”‚                  45.7s                            |  |    |β–’β–’|  
β”‚ ─43.7sβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€44s────44.8s────┼──┼────|β–’β–’|──
β”‚   β”Œβ”€β”€β”            |  |   41.8s    β”Œβ”€β”€β”    β”Œβ”€β”€β”    |  |    |β–’β–’|  
β”‚   |  |            |  |    β”Œβ”€β”€β”    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |            |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    n/a     |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
└───┴──┴────────────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

super(message)

Object.setPrototypeOf(this, new.target.prototype)
this.name = 'FunctionBundlingUserError'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are necessary because typescript does not support extending builtins completely
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget

let scheduledFuncsFound = 0
const scheduledFunctionExpected = imports.some(({ imported }) => imported === 'schedule')
let scheduledFunctionFound = false
let scheduleFound = false
Copy link
Contributor Author

@danez danez Jul 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the logic a little because all we care if schedule was imported once, if someone imports multiple times, then that is fine too as long as one of the imports is used and exported.πŸ€·β€β™‚οΈ

Copy link
Member

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! ✨

Left a question that we might want to address before merging.

src/utils/error.ts Show resolved Hide resolved
@@ -0,0 +1,70 @@
import type { Message } from '@netlify/esbuild'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to extract all the types from index.js into types.js, to avoid a cycle dependency.

@danez danez requested a review from eduardoboucas July 18, 2022 12:02
eduardoboucas
eduardoboucas previously approved these changes Jul 18, 2022
Copy link
Member

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

src/utils/error.ts Outdated Show resolved Hide resolved
@kodiakhq kodiakhq bot merged commit ca005ba into main Jul 18, 2022
@kodiakhq kodiakhq bot deleted the fix/danez/error-message branch July 18, 2022 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotate error when scheduled function is not correctly detected
2 participants