►
Description
The lead maintainer of js-ipfs and js-libp2p will share tips and tricks for debugging js-ipfs
A
So
my
talk
is
debugging
JS
ipfs,
like
a
pro
that
was
the
title
of
the
talk,
I
added
like
a
pro
wrestler.
This
it's
made
a
lot
of
sense
to
me
at
like
2
A.M
when
I
was
writing
these
slides,
yeah
I'm,
not
sure
how
far
I
can
stretch
this
analogy,
but
we'll
see
because
I
yeah
so
I
mean
obviously
there's
like
the
grappling
aspect.
It's
hard.
There's
no
guarantee
of
success.
Also,
like
so
I,
grew
up
in
the
UK
like
in
the
90s.
A
There
wasn't.
There
was
only
terrestrial
TV
at
the
time
and
then
this
thing
came
along
called
Sky
TV,
which
is
like
television
through
your
satellite
amazing.
It's
like
living
in
a
future
and
one
of
the
things
that
was
on
Sky
TV
was
was
WWF
wrestling
and
yeah
like
as
like
10
or
12
year
old
me,
I'm,
not
quite
sure,
on
the
actual
time
scale
that
it
just
seemed
impossibly
exotic
and
now
I
I
lose
I,
lose
so
much
time.
Reading
biographies
and
the
stories
of
what
happened
to
all
these.
A
These
people
on
Wikipedia,
but
all
the
actual
wrestling
shows.
It
always
strikes
me
that
it's
more
like
a
soap
opera
than
actual
sport
I
mean
obviously
a
sport,
there's
incredible
physiques
and
that
kind
of
stuff,
but
but
the
actual
things
that
are
happening
is
like
a
soap
opera
and
like
any
any
soap
opera.
There's
only
was
it
there's
a
famous
start,
there's
like
six
or
eight
plots
to
any
soap
opera
and
they
just
get
repeated
endlessly,
and
then
you
yeah,
and
when
you're
debugging
things
usually
there's.
A
You
know,
there's
a
few
things
that
were
always
bad.
Like
string,
concatenation,
regular
Expressions,
like
memory
copying
that
kind
of
stuff,
so
usually
you
can
find
like
you're
like
yeah.
This
was
probably
it,
but
also
the
one
thing
about
debugging
that
doesn't
apply
to
soap
operas
is
like
measurement
is
super
important.
It's
really
easy
to
go
down
rabbit
holes
chasing
the
wrong
thing,
so
you
must
measure
everything
measure,
absolutely
everything.
A
Yes,
so
who
am
I?
I'm
Alex,
bossidis,
aching
brain
on
the
internet,
I
maintain
I'm
on
the
IP
stewards
team
for
protocol
Labs
I
maintain
JS,
ipfs,
Json
P2P.
A
A
lot
of
the
JS
stack
I
am
hiring.
I
would
like
to
not
maintain
all
these
things
all
the
time
I
would
desperately
like
some
help.
So
please
come
and
talk
to
me
if,
if
you'd
like
to
join
the
team,
so.
A
Logging
debugger
metrics
gonna
go
back
to
logging
briefly
and
then
like
Prometheus
to
actually
get
some
stats
out
and
then
hopefully
are
going
to
fix
a
problem
streaming.
I
can
replicate
it,
so
logging
is
yeah.
So
so
we
have
a
lot
of
logging
in
Js
ipfs.
It's
all
based
on
this,
this
little
PCP
logger
package,
which
really
is
just
using
the
debug
module
it's
behind
this
extra
package,
because
the
bug
is
not
esm
yet
so
at
some
point
we
can.
A
A
You
just
have
the
name
of
the
module,
the
name
of
the
subsystem,
and
you
have
three
three
ways
of
cooling:
it.
You
get
the
the
regular
log,
you
get
a
trace
log
and
you
get
an
error
log
and
we'll
see
how
we
can
pull
these
out
individually
later.
A
To
enable
the
logging,
it's
very
easy,
there's
just
a
an
environmental
variable
debug
and
you
pass
in
a
pattern.
This
also
works
in
browsers.
You
just
set
the
local
storage
variable,
with
the
caveat
that
you
know
with
the
node
version,
if
you
control
C,
and
then
you
start
again
with
just
jsrpfs,
you
won't
see
the
logging
in
the
browser.
A
You
definitely
will
so
if
you
set
it
to
be
something,
that's
too
verbose
and
your
browser
catches
fire,
it
will
catch
fire
as
soon
as
you
restart
the
page
reload,
the
page.
Sorry
so
be
careful
and
you
have
lots
of
options,
so
you
can
have
wild
cards.
A
The
second
one
will
give
you
everything,
it's
very
noisy
and
then
you
can
have
multiples
and
you
can
remove
things.
You
can
do
individual
things.
It's
going
to
start
up.
It's
like
great!
Now
what
it's
a
completely
black
box
I
have
no
idea
what's
happening,
so
I
can
stop.
It.
A
A
Are
very
noisy
nplex
and
Caribou
noises
or
implexes
like
printing
out
the
different
messages
that
are
coming
in
these
are
very,
very
noisy.
So,
let's
just
look
at
like
one
thing.
So
if
we
just
look
at
identifier,
for
example,
we
can
just
do
start
it
up
again
and
now
we'll
only
see
messages
from
identify,
which
is
probably
you
know,
an
interesting
thing
to
choose,
given
that
I
need
some
network
connectivity
in
order
to
actually
run
identify,
and
obviously
this
is
conference
Wi-Fi.
So.
A
Anyway,
I'm
going
to
move
on
so
yeah,
so
you
can
you
can
you
can
have
multiples?
You
can
have
individual
components.
This
is
my
favorite.
One
is
just
to
basically
remove
mobile
stream
select
and
then
remove
all
the
trace
logging
because
it's
very,
very,
very
noisy.
It
would
be
interesting
to
have
a
way
that
doesn't
turn
on
Trace
logging
by
default,
but
that's
the
debug
API.
A
So
yeah,
so
a
more
concrete
example.
Here
we
go
starting
up
showing
all
the
things.
Okay,
that's
Logan.
What
else
so
this
is
a!
This
is
more
like
General
how
to
debug
node
things.
This
is
so
this
is
the
debugger
you.
You
can
obviously
do
this
in
the
browser
too,
and
the
browser
is
super.
Easy.
You
just
pop
open.
The
developer
console
stick
a
breakpoint
in
and
you're
away.
You
have
to
debug
it
all
the
time
and
no
you
don't
so.
A
You've
got
the
inspect
command
that
you
can
start
the
node
with
which
will
create
a
port
and
you
can
connect
to
it
using
the
debugger,
that's
in
every
version
of
Chrome.
So
if
I.
B
A
Want
to
show
the
URL,
so
the
URL
here
you're
gonna,
have
to
take
my
word
for
it.
It's
way
too
far
away.
If
you
want
to
read
it,
but
it's
the
Chrome
colon
inspect
and
then
you'll
see
that
we
have
a
remote
Target
that
we
can
debug.
So
I
can
connect
to
it
like
this
in
the
in
the
console,
I
see
debugger
attached
and
suddenly
here,
I
am
so
I'm.
Now
I
can
now
debug
things
which
is
fantastic,
so
I
can
stick
break
points
in
here.
A
Obviously,
there's
a
lot
of
code
and
we
can
inspect
what's
going
on.
That's
very
useful.
What?
If,
what?
If
my,
what
if
I
forgot
to
start
it
well
I'm
back,
so
that's
useful
in
the
the
Json
versus
started
up
now,
but
what,
if
you
know
you
wanted
to
start
from
the
beginning
of
the
the
process?
So
you
want
to
put
breakpoints
in
maybe
you're
debugging
the
startup
process.
A
A
The
target
is
turned
up
and
I
can
log
on
to
the
debugger,
and
now
it
has
stopped
before
the
very,
very
first
import,
so
now
everything's
suspended
I
can
I
can
go
through
the
source
tree
I
can
stick
things
in
and
debug
where
I
want
to,
obviously,
because
if
you're
debugging
Liberty
to
P
like
this,
because
it's
on
our
typescript,
you
need
to
go
and
put
the
breakpoints
in
the
compiled
JavaScript
rather
than
the
typescript
I'm
sure
there's
a
way
around
it.
A
B
A
So
jsip
versus
all
esm
and
not
not
typescript,
so
I
can
go
into
the
source,
components,
I,
don't
know
index
and
just
stick
a
breakpoint
in
in
our
Constructor
for
ipfs
and
then
just
click.
A
So
I
can
look
at
the
scope.
I
can
see,
the
variables
are
going
to
be
defined.
I
can
see
all
kinds
of
things.
This
is
very
useful.
I
can
step
over
things.
This
is
a
bugger.
The
buggers
are
wonderful.
It's
like
the
Swiss
Army
knife
of
tools,
I
can't
I,
don't
know
what
the
wrestling
analogy
would
be
for
this
I.
Don't
think
there
is
one
so
I
told
you.
I
was
going
to
try
and
stretch
that
analogy
as
far
as
possible,
anyway.
A
B
A
Run
run
hooray
and
then
in
this
window,
I'm
just
going
to
do
a
bit
of
jazz
ipf.
Oh
sorry,
I'm
going
to
do
a
bit
of
itfs
because
it
renames
the
process,
you'll
notice,
the
ipfs
and
not
JS
ipfs,
because
why
not
so
we
have
the
PID
there
so
I
can
just
do,
kill.
Obviously,
don't
forget
the
dash,
if
you
just
desig
user,
one
and
that'll
actually
just
kill
the
process
entirely.
No,
no!
A
So
there
we
go
so
now
the
debug
is
listening.
It's
appeared
in
a
inspector
again
and
I
can
open
the
debugger
and
we're
away
very
useful.
A
Metrics,
sorry,
this
is
great,
but
what
if
I
mean
we
want
like
to
be
able
to
see
things
like
CPU
usage
memory
usage,
there's
a
whole
bunch
of
interesting
metrics
that
ipfs
exposes
and
live
P2P,
but
only
if
you
set
this
ipfs
monitoring
environmental
variable
because
the
metrics
are
not
free.
A
It
saying
this
variable
will
configure
a
matrix
object
within
lipitv
itself.
That
is
then
shared
by
ipfs
to
add
extra
stats
around
like
bit,
Swap
and
and
all
kinds
of
stuff,
but
you
must
specify
the
the
environmental
variable,
ipfs
monitoring,
true
something
else.
This
does
is
it
it
creates
a
so
the
way
Prometheus
pulls
the
stats
out
is
that
it
will
create
an
endpoint
that
the
client
can
call.
It
also
enables
another
endpoint
that
lets
you
dynamically
change,
the
debug
level
for
the
debug
login,
which
is
incredibly
useful.
A
Kill
the
thing
ipfs
monitor,
ing.
B
A
Next,
yeah
logging,
okay,
fine!
So
here
we
go
so
it's
not!
Our
we've
got
the
monitoring
and
then,
if
I
hold
on
there,
it
is
so
we
can
now
now
this
is
running.
There's
an
extra
endpoint,
that's
running
you
can,
if
you're
a
hardcore
use,
Curl
or
wget
or
whatever
to
then
like,
send
a
request.
A
It's
a
post
request,
the
magic
URL
debug
and
then,
but
you
have
to
escape
all
the
colons
and
that
kind
of
thing
like
I,
don't
hate
myself,
so
I'm
not
going
to
do
that,
I'm
going
to
use
an
app
to
do
it
so
I'm,
just
using
this
rest
client.
A
This
is
this
is
just
a
just.
A
simple
client
called
insomnia
that
I
use
to
make
requests
because
I
can
just
type
I
can
just
type
the
the
argument
in.
A
No,
it
doesn't
want
me
so
so
I
just
typed
this
bit
here.
The
question
was:
do
I
still
have
to
URL
encode?
If
I'm
using
this
app?
No
I?
Don't
it
does
it
for
me,
so
it
just
it
generates
the
URL
that
it's
going
to
send
it
to
so
you
could
then
actually
take
this
and
paste
it
into
the
terminal
if
you
wanted
but
yeah,
so
you
can
just
type
the
thing.
A
A
A
Loads
of
like
fun
metrics
in
there,
so
Prometheus
yeah
I'm
not
going
to
go
into
too
much
detail
about
Prometheus.
You
can
go
to
the
website
download
it
super
easy.
You
just
configure
a
job
with
the
you
just
ensure
that
your
config
file
has
scrape
configs
with
the
right
metrics
path
and
host
and
the
port
number.
And
then
you
just
start
Prometheus
with
the
with
the
with
the
config
file,
which
is
great,
and
it
looks
a
bit
like
this.
A
Wherever
it's
gone,
yeah
can't
update
no
don't
reinstall
Chrome
well,
not
now,
where
did
I
put
it
yeah?
So
there
we
go.
A
So
this
is
perimeters,
also
doesn't
very
much
so
we
have
lots
of
useful
queries
in
here.
So,
for
example,
here
we
just
have
like
all
the
memory
usage
by
node
gives
us
a
nice
graph
I'm
going
to
change
it
to
just
be
very
short,
so
we
have
our
node
startup
spikes.
The
memory
goes
right
down
to
something
reasonable,
like
the
green
thing
is
the
interesting
one.
Is
the
amount
of
Heap
size
that
we've
we're
using
so
above
that
there's
the
the
total
Heap
and
then
the
total
memory
usage
from
node.js.
A
A
So
there's
some
interesting
queries.
You
can
run
so
like
there's
no
nice
and
easy
way
of
pulling
CPU
usage
out
Prometheus,
but
you
just
use
this
fantastic
little
function
to
do
it.
You
see
the
memories,
so
the
node
memory
usage
is
actually
a
custom.
One.
That's
added
by
jsrpfs
that
just
like
takes
all
the
node
stats
together
and
puts
them
on
one
graph.
It's
quite
useful,
I
find
and
we
have
some-
we
have
some
specific
Lupita
P
ones.
A
So,
the
like
the
number
of
connections
you
can
instate
the
Specter
bit
Swap
and
we're
adding
more
so
one
thing
that's
happening
like
specifically
with
chainsafe
and
load
star,
is
they're
very,
very
interested
in
the
performance
of
like
the
TCP
transport.
So
there's
a
whole
bunch
of
stats
being
added
around
that.
A
Also
gossip
sub,
like
the
state
of
the
mesh,
the
the
number
of
retries,
like
the
scores
of
various
peers
loads
of
metrics
around
that
with
they've,
actually
they've,
actually
implemented
their
own
metrics
Gathering,
because
the
the
default
load
p2p1
was
lagging
a
little
bit
and
they
needed
it
like
yesterday.
But
it's
very
much
on
the
roadmap
to
try
and
bring
all
those
together
so
that
you
can
get
really
good
stats
out
of
all
the
the
very
high
like
contention
resources
within
your
ipfs
node
yeah.
So
so
we
can
see
in
here.
A
We
have
you
just
like
you,
can
just
type
Liberty
to
p
and
you've
got
all
kinds
of
interesting
things.
So
you've
got
the
the
DHT
routing
table
sizes.
We've
got
some
nplex
stats.
A
number
of
listeners
that
we
have
for
transports
interesting.
Other
interesting
ones
are
like
the
so
the
active
handles.
So
this
is
the
number
of
essentially
the
number
of
sockets
that
you're
holding
open.
A
So
you
would
expect
this
to
track
the
number
of
active
connections
that
you
have
if
you're,
if
the
handles
go
way
above
the
number
of
connections
or
they
keep
growing,
then
you've
got
a
leak
somewhere
and
you
need
to
find
it,
which
is
like
yeah,
more
typical
in
your
average
memory
leak.
A
So
this
is
the
number
of
connections
we
have
obviously
we're
in
a
conference
zone.
So
we're
gonna
see
some
interesting
things,
so
I
haven't
actually
connected
to
anyone,
but
I
have
63
outbound
connections,
so
I'm
dialing
appears
that
I'm
ambiently,
discovering
yeah
Prometheus
is
very
useful.
Gives
you
a
great
window
into
what's
going
on
right?
So
so
it's
been
very
dry
so
far,
but
we're
going
to
try
and
do
something
interesting
now.
So
we're
going
to
put
it
all
together,
so
something
I'm
quite
interested
in
is
that
a
little
Spike
at
the
beginning.
A
We
saw
it
in
the
memory
so
the
beginning
of
your
stars.
Here's
like
the
CPU,
so
this
one's
interesting.
So
there's
this
there's
a
spike
that
goes
down
and
then
we
do
nothing
for
a
bit
and
then
we
go
back
up
something
worth
investigating,
but
I'm
quite
interested
in
this
little
Spike
here
that
when
we
start
so
obviously,
when
you
start
a
note
up,
it's
doing
nothing,
that's
doing
something
so
you're
going
to
start
it's
gonna
I
mean
the
CPU
is
gonna
Spike,
because
you
weren't
doing
anything
and
now
suddenly
you're
doing
something.
A
But
let's
see
what
what's
it
actually
doing.
So,
if
I,
if
I
kill
my
node
and
I'm
going
to
start
it
in
debug
mode
and
take
a
CPU
profile.
B
Go
back
to
the
sources.
Does
this
stuff
ever
work.
A
A
A
It's
going
to
it's
going
to
slow
down
in
self-time
total
time
is
sometimes
more
useful
because
you
can
see
how,
like
you,
can
kind
of
descend
into
the
stack
and
you
can
see
where
the
CPU
time
is
taken
up
and
you
get
more
of
an
idea
of
where,
like
the
the
components
that
are
the
bad
ones
and
that
have
the
that
have
the
the
dependencies
that
are
slow
because
often
the
code
that
is
slow
is
not
your
code.
It's
often
is
often
other
code
that
you're
calling.
A
So
if
we
go
so
we
can
look
at
we've
sort
it
by
the
time
taken.
I
can
look
at
a
callback
trampoline
on
message,
so
this
is
interesting.
So
here
we
go
so
it's
a
datagram,
so
this
is
not
TCP.
This
is
this
is
going
to
be
UDP,
something
that's
happening
so
already,
so
we
start
thinking
right
what
what
do
we
use
for
UDP?
So
there's
no
quicker
node
yet,
but
we
do
other
things
in
the
UDP.
So
some
of
the
things
that
we
do
is
like
mdns
is
all
UDP
events.
A
Oh
look,
there's
mdns,
that's
interesting!
So,
what's
going
on
here,
so
we're
making
our
DNA
so
we'll
use
npns,
for
so
we
use
it
for
local
Discovery
on
the
network,
so
we're
obviously
in
this
Zone
I
mean
how
many
laptops
are
there
in
here.
I
can
see
at
least
like
seven
or
eight
node,
10
15,
and
then
imagine
all
the
other
people
around
there's
a
lot
of
laptops.
A
There's
gonna
be
a
lot
of
mdns
going
on,
so
we
can
go
further
in
and
get
addresses
encapsulate,
so
we
can
obviously
click
through
and
see
what's
happening.
So,
if
I
look
at
this,
where
am
I
I'm
in
I'm
in
multi
other,
oh
that's
interesting,
so
I
can
dig
down
further.
Obviously
the
percentage
is
getting
smaller
and
smaller.
We
go
down
string.
It
will
string
to
bite
hello,
so
we're
doing
something
with
a
string
like
what
do
we
do
with
strings?
A
A
I
think
it's
so
you
don't
dial
rubbish
like
a
string
that
isn't
a
regular
expression
so
anyway,
so
now,
where
are
we
we're
in?
This
is
much,
and
here
we
are
oh
look
as
a
regex,
oh
cool.
So
so
what
we
found
is
we've
drilled
all
the
way
down.
We
found
that
there's
there's
a
slow,
regular
expression
somewhere
in
our
stack,
it's
around
multi-adders
and
like
parsing
multi-adders
from
strings
and
yeah.
So
if
you
actually
look
at,
if
we
actually
look
at
oh,
let
me
get
a
window.
A
I,
don't
know
what
am
I
doing
this
on
conference
Wi-Fi
anyway.
This
came
up
recently
because
lodestar
actually
noticed
that
there
I
must
say
recently
I
mean
like
yesterday,
because
loadstar
actually
noticed
I'm
gonna
switch
onto
my
phone.
A
Yeah,
at
least
I
noticed
that
they
were
consuming
an
awful
lot
of
CPU
usage,
pull
requests,
so
they
yeah,
so
they
found
they
found
that
we're
using
an
awful
lot
of
CPU
usage
in
this
in
load
store.
So
they
did.
They
did
a
very
similar,
very
similar
investigation,
and
so
they
found
actually
in
this
is
IP.
You
can
see
it.
It
was
actually
using
9.75
of
CPE
time
because
they,
they
obviously
have
very
high
traffic
nodes
and
so
there's
a
lot
of
pausing
of
this
stuff.
A
So
that
is
a
that
is
a
terrible,
terrible
start
and
what
they've
done
is
they've
taken
right,
so
they've
they've,
measured
it
and
they've
identified
the
bottleneck
and
what
they've
done
is
they've
taken
they've,
actually
taken
all
the
radio
Expressions
out,
they've
written
a
a
new
regular
expression.
A
Sorry,
a
new
IP
address,
parser,
that's
actually
based
on
the
rust
implementation
and
it's
between
30
and
300
times
faster
than
his
IP,
which
is
great
and
here's
a
here's,
a
PR
that
from
them
very
helpful
which
swaps
it
out
in
multi-adder,
which
is
going
to
solve
our
performance
problem.
This
is
the
power
of
Open
Source.
So
I'm
I'm
just
going
to
merge
that
one.
B
And
yeah
thanks.
A
That's
it
there
we
go
so
we
fixed
our
performance
problem.
Someone
else
fixed
it,
which
is
like
it's.
The
key
to
successful
software
development
is
making
your
problem
someone
else's
problem
and
they've
done
it,
which
is
great.
That's
it
that's
the
talk.