Errors in the sharepoint framework application?

Toriyama 286 Reputation points
2022-09-13T14:35:52.58+00:00

I developed a system in sharepoint framework without javascript parameter and it is ok in production, because it works as expected.
Looking at Azure Insights I see the errors below, but they seem to have no impact on the application as I have no reports from users.

Uncaught TypeError: Failed to construct 'URL': Invalid URL
Uncaught TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
Uncaught TypeError: Cannot read properties of null (reading 'parentNode')

ErrorEvent: Script error.
TypeError: Object does not support property or method 'replaceAll'
Script error.
NotFoundError

The highlighted bugs are still happening in production and the others without highlights have happened more than once, but it's been a while since we have these errors.

What could these errors be? How to solve?

Thanks

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,897 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 34,741 Reputation points Microsoft Vendor
    2022-09-14T09:45:01.103+00:00

    Hi @Toriyama
    We can keep the server's URL in the extension's storage to fix Failed to construct 'URL': Invalid URL. The code looked something like this:

    var stored_url = await get_from_browser_storage('axe_server_url')  
    var url = new URL(stored_url || DEFAULT_SERVER_URL)  
    

    For the second error you can refer to the similar issue in the following link
    https://github.com/prevwong/craft.js/issues/161

    To solve the "Cannot read property 'parentNode' of null" error, place the JS script tag at the bottom of the body. The JS script tag should run after the DOM elements have been loaded


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.