-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution][Exceptions] Handle promise rejections when building artifacts #73831
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { savedObjectsClientMock } from 'src/core/server/mocks'; | |
import { createPackageConfigServiceMock } from '../../../../../../ingest_manager/server/mocks'; | ||
import { ArtifactConstants, ManifestConstants, isCompleteArtifact } from '../../../lib/artifacts'; | ||
|
||
import { getManifestManagerMock } from './manifest_manager.mock'; | ||
import { getManifestManagerMock, ManifestManagerMockType } from './manifest_manager.mock'; | ||
import LRU from 'lru-cache'; | ||
|
||
describe('manifest_manager', () => { | ||
|
@@ -204,5 +204,14 @@ describe('manifest_manager', () => { | |
oldArtifactId | ||
); | ||
}); | ||
|
||
test('ManifestManager handles promise rejections when building artifacts', async () => { | ||
// This test won't fail on an unhandled promise rejection, but it will cause | ||
// an UnhandledPromiseRejectionWarning to be printed. | ||
const manifestManager = getManifestManagerMock({ | ||
mockType: ManifestManagerMockType.ListClientPromiseRejection, | ||
}); | ||
await expect(manifestManager.buildNewManifest()).rejects.toThrow(); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this test passes without the changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We zoomed. It passes either way, but an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @madirey explained to me, as posted in the comment, the test will pass without those changes, but the changes prevent the rejection warning from appearing when running the tests. The rejection does get handled further down the line when building the manifest. |
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ think you want
!==
instead of!=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkimmel Maybe I misunderstood, but I thought the prevailing recommendation was that
!= null
is preferable to!== undefined
because it catches bothnull
andundefined
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but coercively.
==
and it's!=
cousin hurt to read. That fancy new nullish coalescer??
could come in handy, since it's made to handle undefined/null likeif(opts?.cache ?? false)
maybe,