@@ -13,20 +13,21 @@ import { light } from './theme_light';
1313
1414import { TEMPLATE_TYPE } from '../../common/lib/constants' ;
1515
16- export const templates = [ pitch , status , summary , dark , light ] ;
16+ export const templates = [ status , summary , dark , light , pitch ] ;
1717
1818export async function initializeTemplates (
19- client : Pick < SavedObjectsRepository , 'bulkCreate' | 'find' >
19+ client : Pick < SavedObjectsRepository , 'bulkCreate' | 'create' | ' find'>
2020) {
2121 const existingTemplates = await client . find ( { type : TEMPLATE_TYPE , perPage : 1 } ) ;
2222
2323 if ( existingTemplates . total === 0 ) {
24- const templateObjects = templates . map ( ( template ) => ( {
25- id : template . id ,
26- type : TEMPLATE_TYPE ,
27- attributes : template ,
28- } ) ) ;
29-
30- client . bulkCreate ( templateObjects ) ;
24+ // Some devs were seeing timeouts that would cause an unhandled promise rejection
25+ // likely because the pitch template is so huge.
26+ // So, rather than doing a bulk create of templates, we're going to fire off individual
27+ // creates and catch and throw-away any errors that happen.
28+ // Once packages are ready, we should probably move that pitch that is so large to a package
29+ for ( const template of templates ) {
30+ client . create ( TEMPLATE_TYPE , template , { id : template . id } ) . catch ( ( err ) => undefined ) ;
31+ }
3132 }
3233}
0 commit comments