question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object

See original GitHub issue

Hi! Thanks for all the work you’ve put into this project. I’m following the quick start tutorial and have managed to set things up, after a some setbacks with simple_oauth library.

But, currently, I’m having an issue viewing my blog posts. I can see them at the home page and can also see that all their content is fetched in home page, as a collection. But once I visit a specific one (blog/first-post, as in blog/[node:title]), I get a 404 in the Network tab in Google Chrome.

And also this error.

 1 of 1 unhandled error

Unhandled Runtime Error
Error: Failed to load script: /_next/static/chunks/pages/404.js

Source
.next\static\chunks\main.js (83:51) @ HTMLScriptElement.script.onerror

  81 | //    executes when `src` is set.
  82 | script.onload = resolve;
> 83 | script.onerror = ()=>reject(markAssetError(new Error(`Failed to load script: ${src}`)))
     |                                           ^
  84 | ;
  85 | // 2. Configure the cross-origin attribute before setting `src` in case the
  86 | //    browser begins to fetch.

I guess the following error is due to not getting any data in the response.

error - TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object
    at Function.byteLength (buffer.js:726:11)
    at ServerResponse.apiRes.end (C:\Users\trogl\Desktop\next-next-next\node_modules\next\dist\server\api-utils.js:72:41)
    at C:\Users\trogl\Desktop\next-next-next\node_modules\next-drupal\dist\index.js:566:30
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.apiResolver (C:\Users\trogl\Desktop\next-next-next\node_modules\next\dist\server\api-utils.js:101:9)
    at async DevServer.handleApiRequest (C:\Users\trogl\Desktop\next-next-next\node_modules\next\dist\server\next-server.js:770:9)
    at async Object.fn (C:\Users\trogl\Desktop\next-next-next\node_modules\next\dist\server\next-server.js:661:37)
    at async Router.execute (C:\Users\trogl\Desktop\next-next-next\node_modules\next\dist\server\router.js:205:32)
    at async DevServer.run (C:\Users\trogl\Desktop\next-next-next\node_modules\next\dist\server\next-server.js:841:29) {
  code: 'ERR_INVALID_ARG_TYPE',
  page: '/api/preview'
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:29

github_iconTop GitHub Comments

3reactions
taku3202commented, Oct 18, 2021

I am experiencing the same phenomenon.

TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object
    at new NodeError (node:internal/errors:371:5)
    at Function.byteLength (node:buffer:733:11)
    at ServerResponse.apiRes.end (/opt/preview/.docker/preview/node_modules/next/dist/server/api-utils.js:72:41)
    at /opt/preview/.docker/preview/node_modules/next-drupal/dist/index.js:593:30
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.apiResolver (/opt/preview/.docker/preview/node_modules/next/dist/server/api-utils.js:101:9)
    at async Server.handleApiRequest (/opt/preview/.docker/preview/node_modules/next/dist/server/next-server.js:770:9)
    at async Object.fn (/opt/preview/.docker/preview/node_modules/next/dist/server/next-server.js:661:37)
    at async Router.execute (/opt/preview/.docker/preview/node_modules/next/dist/server/router.js:205:32)
    at async Server.run (/opt/preview/.docker/preview/node_modules/next/dist/server/next-server.js:841:29) {
  code: 'ERR_INVALID_ARG_TYPE'

The version I am using is as follows.

  • next-drupal: 0.16.2
  • next.js (Drupal Module): 1.0.0-beta5

I refer to this code, On the Drupal side, the page loaded successfully by applying the following patch to the subrequests module.

        "patches": {
+	    "drupal/subrequests": {
+                "Subrequest failed validation": "https://www.drupal.org/files/issues/2019-05-27/3029570-array-not-object.patch",
+                "Get same results on different request": "https://www.drupal.org/files/issues/2019-07-18/change_request_type-63049395-09.patch"
+            }
        },


1reaction
KojoEnchcommented, Nov 1, 2021

I faced the same issue (Drupal 9.2). As per @taku3202 comment, applying Drupal Subrequests patches solved it :

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - nodejs - first argument must be a string or Buffer
I'm simply trying to create a node server that outputs the HTTP status of a given URL. When I try to flush the...
Read more >
The "string" argument must be one of type string, Buffer, or ...
I get the error: The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type object.
Read more >
The first argument must be of type string or an instance of Buffer
TypeError: The "string " argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object comes...
Read more >
ArrayBuffer - JavaScript - MDN Web Docs
Chrome Edge ArrayBuffer Full support. Chrome7. Toggle history Full support. Edge12. Tog... @@species Full support. Chrome51. Toggle history Full support. Edge13. Tog... ArrayBuffer() constructor Full support....
Read more >
Stream | Node.js v18 API
Stream instances are switched into object mode using the objectMode option ... For streams not operating in object mode, chunk must be a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found