Skip to content

Commit 7acd104

Browse files
committed
fix bug
1 parent bda5e5e commit 7acd104

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

lib/container.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,6 @@ class Container {
202202
static append(newContainer) {
203203
container = deepMerge(container, newContainer)
204204

205-
// If new helpers are added, set the helpers property on them
206-
if (newContainer.helpers) {
207-
for (const name in newContainer.helpers) {
208-
if (container.helpers[name] && typeof container.helpers[name] === 'object') {
209-
container.helpers[name].helpers = container.helpers
210-
}
211-
}
212-
}
213-
214205
// If new support objects are added, update the proxy support
215206
if (newContainer.support) {
216207
const newProxySupport = createSupportObjects(newContainer.support)
@@ -301,7 +292,7 @@ async function createHelpers(config) {
301292
if (!HelperClass) {
302293
const helperResult = requireHelperFromModule(helperName, config)
303294
if (helperResult instanceof Promise) {
304-
// Handle async ESM loading
295+
// Handle async ESM loading - create placeholder
305296
helpers[helperName] = {}
306297
asyncHelperPromise = asyncHelperPromise
307298
.then(() => helperResult)
@@ -320,8 +311,7 @@ async function createHelpers(config) {
320311

321312
checkHelperRequirements(ResolvedHelperClass)
322313
helpers[helperName] = new ResolvedHelperClass(config[helperName])
323-
if (helpers[helperName]._init) await helpers[helperName]._init()
324-
debug(`helper ${helperName} async initialized`)
314+
debug(`helper ${helperName} async loaded`)
325315
})
326316
continue
327317
} else {
@@ -341,9 +331,8 @@ async function createHelpers(config) {
341331
throw new Error(`Helper class from module '${helperName}' is not a class. Use CJS async module syntax.`)
342332
}
343333

344-
debug(`helper ${helperName} async initialized`)
345-
346334
helpers[helperName] = new ResolvedHelperClass(config[helperName])
335+
debug(`helper ${helperName} async CJS loaded`)
347336
})
348337

349338
continue
@@ -358,19 +347,17 @@ async function createHelpers(config) {
358347
}
359348
}
360349

361-
// Set helpers property on each helper to allow access to other helpers
362-
for (const name in helpers) {
363-
if (helpers[name] && typeof helpers[name] === 'object') {
364-
helpers[name].helpers = helpers
365-
}
366-
}
367-
368-
// Wait for async helpers and call _init
350+
// Wait for all async helpers to be fully loaded
369351
await asyncHelperPromise
370352

353+
// Call _init on all helpers after they're all loaded
371354
for (const name in helpers) {
372-
if (helpers[name]._init) await helpers[name]._init()
355+
if (helpers[name]._init) {
356+
await helpers[name]._init()
357+
debug(`helper ${name} _init() called`)
358+
}
373359
}
360+
374361
return helpers
375362
}
376363

lib/helper/REST.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ class REST extends Helper {
468468
export { REST as default }
469469

470470
function curlize(request) {
471-
if (request.data?.constructor.name.toLowerCase() === 'formdata') return 'cURL is not printed as the request body is not a JSON'
471+
// Guard access to nested properties safely in case request.data is undefined
472+
if ((request.data?.constructor?.name || '').toLowerCase() === 'formdata') return 'cURL is not printed as the request body is not a JSON'
472473
let curl = `curl --location --request ${request.method ? request.method.toUpperCase() : 'GET'} ${request.baseURL} `.replace("'", '')
473474

474475
if (request.headers) {

0 commit comments

Comments
 (0)