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.

Bug - Uncaught (in promise) TypeError: fn is not a function

See original GitHub issue

Important

This error only occurs in Routify v2.16.0. I’ve tried Routify v2.14.0, but the error doesn’t happen.


Bug Description

I get this error when click the back button of the browser. In other case, i got this error also when navigate to another page that contain metatags helper.

image


How to get this error?

  1. Clone the Routify Starter template using npx degit roxiness/routify-starter routify-starter
  2. Goto the project directory: cd routify-starter
  3. Prepare module: pnpm i
  4. Run: pnpm dev
  5. Create new file with name test.svelte in src/pages
  6. Put some code to that file. For me, i put this code:
<script>
  import { onMount } from 'svelte';
  import { metatags } from '@roxi/routify';

  onMount(() => {
    new Promise((resolve) => setTimeout(resolve, 3000)).then(() => {
      $metatags.title = 'Hello world';
      $metatags.description = 'Lorem ipsum dolor suila vot';
    });
  });
</script>

<h1>Hello world</h1>
  1. Add a link with the destination to test.svelte page:

Example

src/pages/example/_components/RoutifyIntro.svelte

<h1>Routify Starter</h1>

To see an example app, go to 
<a href="/example">/example</a>
<a href="/test">/Test</a> // Add this

<p>To delete the example app, simply delete the ./src/pages/example folder.</p>
  1. and then open your browser, and goto http://localhost:5000/.
  2. Open your Browser Console (or Dev Tools).
  3. Click Test link that was created before.
  4. Click back button of your browser.
  5. You will get this error in your browser console.

Environment

  • Routify v2.16.0
  • Svelte v3.29.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostdevvcommented, Mar 23, 2021

@lamualfa From what I can tell $metatags will work fine in prod, it’s being weird with svelte-hmr so you can just manually reload effected pages till we find out exactly what causes the hmr issue and fix it. But you shouldn’t have any issues in production

Basically svelte-hmr just hot module reloads page data when changes are made, so you will see this error whenever you save a file in development mode, but to fix you can just reload the page manually

1reaction
lamualfacommented, Mar 19, 2021

First of all, I am sorry. It seems that the description I gave is unclear. Therefore I try to summarize.


Below v2.16.0 (this issue was not shown for this version)

The problem only occurs in metatags that use the store. Meanwhile in this version Routify doesn’t support metatags as store. So it can be concluded that the issue I created this time was not shown for this version.


v2.16.0 and above

In this version Routify has been used metatags as a store. If you use this version and then use metatags as a store, you will get this error:

image

For more detail about on how to get this error i have explained above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve "TypeError: fn is not a function"? - Stack Overflow
I'm trying to implement Passport.JS and JWT functionality into my nodejs application and receive the following error.
Read more >
Uncaught TypeError: fn is not a function when modify shared ...
In this case I'm getting "fn is not a function" error when trying to load "host2" app. Only when I add additional script...
Read more >
Type error: fn is not a function. I don't know how to fix that.. Any ...
I've been trying to code a Discord bot to do a Timed mute, but there seems to be an error which I don't...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
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